setPersistentCache should add tags by entity

Created on 25 February 2021, over 3 years ago
Updated 26 January 2023, almost 2 years ago

Problem/Motivation

At core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php on setPersistentCache function, cache entries are created with tags that are too generic. We can use the entity information to also add tags specific to each entity in order to have a better cache invalidation.

Our particular issue is related to Memcache entries that when not cleared properly are showing multiple current revisions in the revisions table, and using the previous current revision for rendering the node.

Steps to reproduce

(Detailed instructions on how to reproduce the issue, including exact versions used, specific paths to visit, what actions to take, etc.)

Inspecting cache entries I noticed that the data for the cache entry that was not being invalidated properly has only 'node_values' & 'entity_field_info' tags, which is missing useful entity cache tags.

Proposed resolution

Append the entity that is being stored as data in the cache entry.

Remaining tasks

(reviews needed, tests to be written or run, documentation to be written, etc.)

  • make patch (or branch) for change in most recent dev version (9.2.x)
  • update steps to reproduce, starting from install drupal core
  • get review for
    • if this change can/should be made,
    • and if so, is this an ok place for the change, or is there another place that it should be made,
    • does this need tests or changes to tests.

User interface changes

None expected.

API changes

None intended.

Data model changes

None intended.

Release notes snippet

(Major and critical issues should have a snippet that can be pulled into the release notes when a release is created that includes the fix)

TBD. Might change as this gets reviewed, right now this issue is "Normal", not Major or Critical.

🐛 Bug report
Status

Needs work

Version

9.5

Component
Entity 

Last updated about 1 hour ago

Created by

🇪🇨Ecuador BetoAveiga Daule, Guayas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024