Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293242

Bubbling cache tag metadata when rendering nodes in preprocess functions is difficult

$
0
0

Problem/Motivation

Cache tags are brilliant when they work well, and can be obtuse and difficult to use when they don't.

In the case of preprocessing nodes, it's quite difficult to find a way to make sure that node cache tags bubble correctly. Consider this use case (seemingly pretty common):

  1. "Parent" nodes have one "Child" node associated with it.
  2. The Parent node should render the Parent node, then render the Child node in 'Parent teaser' view mode.
  3. Themer decides to use a preprocess function to preprocess the Parent node, then get the render array using something like $view_builder->viewMultiple($child_node, 'parent_teaser'), then the Twig template prints the teaser.
  4. Content admins complain that when they save updates to the "Child" node, the "Parent" doesn't reflect changes until the entire site's cache is cleared.

Apparently Views'viewRenderable() method sets all the cache contexts/tags correctly—we need something similar for getting the render arrays for nodes in general...

Proposed resolution

Either document how to add the appropriate cache contexts/tags when rendering a node via preprocess functions, or add functionality to make this easier to do.

Remaining tasks

TBD

User interface changes

N/A

API changes

TBD

Data model changes

N/A


Viewing all articles
Browse latest Browse all 293242

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>