Problem/Motivation
Currently the only option to reset an individual controller's static cache is to invoke the ::resetCache() method. Unfortunately this also triggers a clear of the persistent cache, which is wasteful and in some edge cases (e.g. while dumping a database) may lead to errors, due to tables being truncated, which is not a transactional-safe operation.
A workaround for this is invoking drupal_static_reset(), which clears entity_get_controller()'s static cache, leading to new controllers being instantiated. However, if there are lingering references to the old controller instances, those will still have a stale entity cache, which may lead to inconsistent behaviors and crazy to debug™ scenarios.
Proposed resolution
Add a new EntityCacheEntityControllerInterface for entity cache-aware controllers exposing a ::resetStaticCache() method.
Remaining tasks
- Validate the prosed solution
Post a patch- Reviews
User interface changes
None
API changes
Only additions
Data model changes
None
Release notes snippet
A new method is available for entity cache-aware controllers to reset only static cache.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | entitycache-reset_static-3021963-6.patch | 6.86 KB | plach |
Comments
Comment #2
plachComment #3
plachThe previous patch was missing a new file.
Comment #6
plachLet's try this
Comment #7
plachAn implementation of
EntityCacheEntityControllerInterfacefor Entity-provided controllers was posted at #3021974-2: Implement EntityCacheEntityControllerInterface.Comment #8
catchLooks good to me - can't find anything to complain about.
Comment #10
catchCommitted/pushed to 7.x-1.x, thanks!
Comment #11
plachAdded a CR at https://www.drupal.org/node/3022024, thanks!