• Resolved Saša

    (@stodorovic)


    Functions wp_cache_get and wp_cache_set work as persistent cache if you have installed Redis, Memcache or something like this. ( https://codex.wordpress.org/Class_Reference/WP_Object_Cache#Persistent_Cache_Plugins )

    Loco uses wp_cache in src/package/Plugin.php. It stores results of function get_plugins. Our advice is adding simple function which purges cache on each activation/deactivation of plugins. Good way is to use hooks: pre_update_option_active_plugins and pre_update_site_option_active_sitewide_plugins.

    Possible fix is:

            add_filter( 'pre_update_option_active_plugins', array( $this, 'pre_update_option_active_plugins' ) );
            add_filter( 'pre_update_site_option_active_sitewide_plugins', array( $this, 'pre_update_option_active_plugins' ) );
    .....
        public function pre_update_option_active_plugins( $plugins ) {
            wp_cache_delete('plugins','loco');
            return $plugins;
        }
    

    We’ve tested our fix and it works fine. When we install/activate new plugin, list of plugins in Loco is refreshed. I hope that you will add similar code in next release.

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tim W

    (@timwhitlock)

    Thanks for the tip.

    I wasn’t aware that persistent caching would ever be done via this API as that is what the Transients API is for.

    You’re right that plugin deactivation should purge any data left kicking around. I will add something into the development trunk shortly and post back here.

    This still leaves the issue that the plugin list won’t be invalidated when simply adding a theme/plugin to the file system, but that has yet to be reported as a problem.

    Plugin Author Tim W

    (@timwhitlock)

    I’ve pushed an update to the dev trunk.

    Ideally I’d purge Loco’s plugin cache whenever WordPress calls wp_clean_plugins_cache but this has no hooks. Thanks for your suggestions, I’ve used them.

    Thread Starter Saša

    (@stodorovic)

    Thank you very much!

    I just installed the development version. It works correctly now. I’ll do more tests and I’ll send feedback if I find better way for triggering purge_wp_cache.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Object cache – get_plugins has permanently cached’ is closed to new replies.