- Issue created by @nuez
- @nuez opened merge request.
- Status changed to Needs review
almost 2 years ago 8:06am 26 January 2023
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.
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.
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.
Write tests.😎
Needs review
1.0
Views integration