Problem
Steps to reproduce:
- Enable mongodb_cache, configure the site to use it instead of core database cache.
- Change site configuration, disable some modules, etc.
(In my case, I did use and develop the site like this for a year or so, but this is not necessary to reproduce) - Switch back to core database cache.
(Or alternatively, use a different cache plugin for drush and for web.)
Expected:
Start with a clean cache.
Actual:
Database cache is still filled with old cache data:
- Old modules that have long been disabled.
- Old hook implementations that no longer exist.
- Theme hooks that no longer exist.
- etc.
This causes a variety of error messages, and breaks the site.
Drupal versions?
So far I encountered this on Drupal 7.
I don't know if the same problem happens on D8.
Manual fix
In my case I managed to fix this manually:
- delete data from all cache tables
- then flush the cache (I think some data is not in cache tables but elsewhere).
Proposed change
I see two options:
1. Detect that cache data is outdated, even if the flushing happened in a different cache storage plugin.
2. Provide an easy and documented way to recover from the situation above.