Adjust caching logic of LayoutBuilderAccessCheck::access()

Created on 10 May 2024, 9 months ago

Problem/Motivation

The logic of RefinableCacheableDependencyTrait::addCacheableDependency() has been updated in #3232018: Trigger an error when using \Drupal\Core\Cache\RefinableCacheableDependencyTrait::addCacheableDependency with a non CacheableDependencyInterface object β†’ .

If the passed object is NOT an instance of CacheableDependencyInterface
Previous behavior: max-age is set to 0
Future behavior: an exception is thrown

In order to get rid of the deprecation notice and preserve the old behavior, one bit of LayoutBuilderAccessCheck::access() code was changed from

$access->addCacheableDependency($section_storage);

to

if ($section_storage instanceof CacheableDependencyInterface) {
  $access->addCacheableDependency($section_storage);
}
else {
  $access->setCacheMaxAge(0);
}

However, it was noticed that SimpleConfigSectionStorage is the only class that does not implement CacheableDependencyInterface.

Maybe SimpleConfigSectionStorage should be extended to implement CacheableDependencyInterface? Then the if condition could be removed.

Steps to reproduce

Proposed resolution

Remaining tasks

- Make a decision
- Update the code?

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component
Layout builderΒ  β†’

Last updated about 7 hours ago

Created by

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

Comments & Activities

Production build 0.71.5 2024