Missing custom entity cache tags in setPersistentCache

Created on 1 July 2024, 5 months ago

Problem/Motivation

We're using two kinds of custom storage clients which extract parent objects as well as nested objects from the response of an external source. Those nested objects are then exposed as individual sub-entities (like paragraphs) referenced by a common parent entity.

When the parent entity is invalidated, we want its sub-entities to be invalidated as well. For this we add the cache tag of the parent entity to the cache tags of each nested entity in hook_entity_storage_load. Unfortunately those custom cache tags are currently ignored by ExternalEntityStorage::setPersistentCache when it stores external entities to the cache backend.

Steps to reproduce

  1. Add an external entity type test and configure it as cacheable
  2. Build a custom module which adds a custom cache tag to test entities in hook_entity_storage_load
  3. Invalidate the custom cache tag manually after loading any test entity
  4. The cached test entities are unaffected by the invalidation

Proposed resolution

Instead of directly building the entities cache tags in setPersistentCache, call getCacheTags() instead to receive any custom cache tags as well.

Remaining tasks

Review needed.

🐛 Bug report
Status

RTBC

Version

2.0

Component

Code

Created by

🇩🇪Germany rob_pr

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024