APCu cache collisions upon activating a staging clone in the same server pool, same WP_CACHE_KEY_SALT
https://wordpress.org/support/topic/site-db-reverted/
Cache values get clobbered on staging sites.
To reproduce:
- Turn on APCu.
- Clone a site to a different SNI hostname or something.
- 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.
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
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?