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.

Comments

plach created an issue. See original summary.

plach’s picture

Assigned: plach » Unassigned
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new5.37 KB
plach’s picture

StatusFileSize
new6.06 KB

The previous patch was missing a new file.

The last submitted patch, 2: entitycache-reset_static-3021963-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Status: Needs review » Needs work

The last submitted patch, 3: entitycache-reset_static-3021963-3.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

plach’s picture

Status: Needs work » Needs review
StatusFileSize
new1.59 KB
new6.86 KB

Let's try this

plach’s picture

An implementation of EntityCacheEntityControllerInterface for Entity-provided controllers was posted at #3021974-2: Implement EntityCacheEntityControllerInterface.

catch’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me - can't find anything to complain about.

  • catch committed 9178ee6 on 7.x-1.x authored by plach
    Issue #3021963 by plach: Add a way to clear only static cache
    
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 7.x-1.x, thanks!

plach’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.