Several methods in BuildFieldTrait were performing access checks and loading config entities (like image styles) without capturing the cache metadata from those operations. This meant that when access results changed
(e.g., an entity was published or unpublished) or config was updated (e.g., an image style was modified), the cached page would not be invalidated.
The following methods now add cache metadata from access results and config entities to $this->cacheableMetadata:
buildEntities()— Access results from$entity->access('view', NULL, TRUE)are now added as cacheable dependencies.getReferencedEntitiesFromField()— Same access result caching, and the access check and entity-missing logic are separated for clarity.getLinkFieldValues()— URL access results are now captured as cacheable dependencies.getMediaImageAndAlt()— Media entities and loadedImageStyleconfig entities are now added as cacheable dependencies. Returns early if the image style does not exist.getImageAndAlt()—ImageStyleconfig entities are now added as cacheable dependencies. Image field references are loaded without access check (since file access is handled separately).
Returns early if the image style does not exist.buildMediaResponsiveImage()— Media entities are now added as cacheable dependencies.
What this means for existing code
All access checks that previously used the boolean return (->access('view')) now use the full access result object (->access('view', NULL, TRUE)). This is a caching-only change — the access logic itself is
unchanged.
If you have custom code that relies on BuildFieldTrait methods, no changes are needed. Cache invalidation will now work correctly for access changes and config entity updates without any action on your part.
Update path
No updates required. This is a bugfix that improves cache metadata propagation. Existing sites will benefit automatically after updating the module and clearing caches.