sqlite-object-cache icon indicating copy to clipboard operation
sqlite-object-cache copied to clipboard

APCu cache collisions upon activating a staging clone in the same server pool, same WP_CACHE_KEY_SALT

Open OllieJones opened this issue 5 months ago • 2 comments

https://wordpress.org/support/topic/site-db-reverted/

Cache values get clobbered on staging sites.

To reproduce:

  1. Turn on APCu.
  2. Clone a site to a different SNI hostname or something.
  3. Restore it in the same php_fpm or apache pool as the original site.

When a site is cloned (to a staging copy of the site for example) within the same server pool the APCu cache gets corrupted.

This is probably also an issue with other users of WP_CACHE_KEY_SALT.

Workaround:

Disable the APCU caching before cloning. Deactivate the plugin before cloning. Change the WP_CACHE_KEY_SALT after cloning. Then, and only then, reactivate the plugin and re-enable APCu.

OllieJones avatar Jul 14 '25 20:07 OllieJones

Here's a note from the Duplicator support team about a hook to detect first login after restoring a clone or backup.

I got feedback from the development team that you use a hook provided by Duplicator that is triggered when the user logs in for the first time after a successful migration.

You can use this hook for Duplicator Pro:duplicator_pro_first_login_after_install

And this hook for Duplicator Lite:duplicator_first_login_after_install

For more information, please refer to the plugin hooks reference:https://duplicator.com/knowledge-base/plugin-hooks/

I hope this helps.

Thanks!

Post Link: https://wordpress.org/support/topic/how-can-an-object-cache-plugin-tell-when-a-site-has-just-been-restored/#post-18590027

OllieJones avatar Oct 09 '25 16:10 OllieJones

Redis Object Cache uses its own WP_REDIS_PREFIX constant instead of WP_CACHE_KEY_SALT. I set it to 'basename(dirname(__FILE__))' which changes it automatically in the environments I use when you set a staging site, as it'll be in a different directory (eg /home/systemuser/site_staging/)

Perhaps something like that can be done here - either suggesting in readme or even implemented?

nickchomey avatar Nov 26 '25 01:11 nickchomey