Views result cache does not apply cacheable metadata from Entity API's query access conditions

Created on 25 January 2023, almost 2 years ago
Updated 26 January 2023, almost 2 years ago

Problem/Motivation

Views caches the results and applies cache tags from the SQL query, but not from the conditions that are applied to the entity query.

in Drupal\views\Plugin\views\query::getCacheTags only the cache tags belonging to the entities of each row are applied. If any other cache dependency was defined in the entity access query conditions, they will not be taken into account when views caches the results, as a result the view cache will not be invalidated when it needs to.

Steps to reproduce

Create a custom entity with a "query_access" handler, and make it somehow depend on a cache tag unrelated to the entities in the views result itself. Load the view, change something that might affect the view and invalidate the corresponding cache tag, and then load the view again.

Proposed resolution

My proposal is to pass the cacheable metadata to the Views executable object as a dynamic property, and then pick it up in a custom Views Cache plugin that can be enabled in those views that need it.

Remaining tasks

Write tests.😎

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs review

Version

1.0

Component

Views integration

Created by

🇪🇸Spain nuez Madrid, Spain

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

Comments & Activities

Production build 0.71.5 2024