Draft: Add discovery cache backend chain to invalidate in-request plugin definition cache
Problem
Drupal\Core\Plugin\DefaultPluginManager uses DiscoveryCachedTrait::$definitions as an in-request cache of plugin definitions. When a plugin manager uses cache tags and those tags are invalidated, only the persistent cache bin is invalidated; the in-request $definitions cache remains stale for the rest of the request.
Solution
- Add a
cache.discovery_chainbackend chain (similar tocache.asset_chain) that combines:-
cache.memory(in-request, tag-aware) -
cache.discovery(persistent discovery cache bin)
-
- Update
default_plugin_managerto usecache.discovery_chaininstead ofcache.discovery.
This preserves the memory-layer performance benefits while ensuring cache tag invalidation also affects the in-request layer.
Tests
- Added
core/tests/Drupal/KernelTests/Core/Cache/DiscoveryCacheChainTest.phpto verify thatCache::invalidateTags()invalidates entries set viacache.discovery_chain.
Files changed
core/core.services.ymlcore/tests/Drupal/KernelTests/Core/Cache/DiscoveryCacheChainTest.php
Closes #3579767