Not working properly when processed with wp-cli cron
-
Thanks for making a lean and effective caching plugin. I’ve recently discovered an issue, though.
This stems from “Clear all cache files when a post or page is published or updated” not working when using WP-CLI to run the WordPress cron instead of the web request method. But it probably has broader implications as well.
The variable
$wp_cache_clear_on_post_edit
is intended to be global, but it is not when run from the WP-CLI. This is because WP-CLI loads WordPress from inside a function, so if a variable is not explicitly declared as global, it is not global in that context. See: https://github.com/wp-cli/wp-cli/issues/4019. Since the variable effectively evaluates to false in this context, the option mentioned above does not work.We are getting around this issue by placing
global $wp_cache_clear_on_post_edit;
inside an mu-plugin. This works because it runs before WP Super Cache, so it preemptively declares it as global.I imagine there may be other variables that are intended to be global that don’t work within the WP-CLI context, but this is the one that has been causing us issues since our move to running cron with WP-CLI.
- You must be logged in to reply to this topic.