• Resolved KratosGemini

    (@kratosgemini)


    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Donncha O Caoimh (a11n)

    (@donncha)

    Thanks, that is a bug. It has to be added to the globals list around here. We’ll get this fixed.

    This PR should fix the problem. I also added any other globals I could find.

    Thread Starter KratosGemini

    (@kratosgemini)

    I tested the PR by copying wp-cache.php to my local install, and I can confirm is solves the cache clear issue I mentioned in this thread. Looking forward to the next release. Until then, we have our mu-plugin workaround.

    Thread Starter KratosGemini

    (@kratosgemini)

    Edit: Accidental duplicate reply

    • This reply was modified 2 days, 21 hours ago by KratosGemini.
    Plugin Support Stef (a11n)

    (@erania-pinnera)

    Hey @kratosgemini,

    Thanks for taking the time to confirm the workaround works for now. Keep an eye on the next WP Super Cache plugin updates, and when it happens let us know if that doesn’t solve the issue – so we can investigate further 🙂

    I’m going to mark this thread as solved for now. If you have any further questions or need more help, you’re welcome to open another thread here. Cheers!

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.