Running code before object-cache.php runs
I want to polyfill some functions before object-cache.php
runs. I have PHP7 and APCu installed. However, W3 Total Cache is using apc_*
functions, not apcu_*
functions. W3 Total Cache's object cache runs using object-cache.php
, which is loaded before any plugins run.
How can I run custom code before W3 Total Cache runs without modifying WordPress core? I also can't use PHP's auto_prepend_file
because WordFence is using it.
Here is the code I want to run:
if (function_exists('apcu_add') !function_exists('apc_add')) {
function apc_add() {
return call_user_func_array('apcu_add', func_get_args());
}
function apc_cache_info() {
return call_user_func_array('apcu_cache_info', func_get_args());
}
function apc_cas() {
return call_user_func_array('apcu_cas', func_get_args());
}
...
}
I might just paste it into wp-config.php
.