Non-lazy ViewsReferenceFieldFormatter always sets cache max-age to 0

Created on 2 May 2024, about 2 months ago
Updated 17 May 2024, about 1 month ago

Problem/Motivation

The non-lazy formatter uses addCacheableDependency($view) yet the addCacheableDependency() method bails as soon as it sees that the object does not implement CacheableDependencyInterface (which views does not).

Steps to reproduce

Use the non-lazy formatter and check the #cache on the render, it will always have max-age of 0. You can see this here.

Screenshot of the line that always gets hit now for convenience (but available in more accessible format via the link above):

Proposed resolution

Respect the #cache from the View by using CacheableMetadata to merge the View #cache onto the $element.

Remaining tasks

Merge request incoming

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom scott_euser

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024