[PP-1] Node/comment views-based theme suggestions have no cacheability metadata

Created on 18 May 2016, over 8 years ago
Updated 7 October 2024, 4 months ago

Problem/Motivation

See views_theme_suggestions_node_alter(), and views_theme_suggestions_comment_alter(), also the code in views_preprocess_node() and views_preprocess_comment() actually.

That does stuff on $node->view. Which is assigned by views when displaying a node. But there is no cache context for this, can't really be, so it is not cached correctly.

Related to πŸ› template_preprocess_node() does not add cacheability metadata Needs work as well.

Proposed resolution

The only thing I can think of is to implement hook_entity_build_defaults_alter() and there, based on the view id and display, define a cache key. The obvious downside is that it results in more cache variations.

I'm also not 100% sure that it is completely accurate then. hook_entity_build_defaults_alter() has some limitations, if dynamic page cache doesn't know about those conditions. But that already has to know about the view/display, if not, you already have a problem.

I think as a long term solution, we should deprecate $node->view and everything that depends on it, but there is no way to make that obvious in something like twig theme suggestions debug output, so people will continue to use it.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Postponed

Version

11.0 πŸ”₯

Component

views.module

Created by

πŸ‡¨πŸ‡­Switzerland berdir Switzerland

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024