Problem/Motivation

I noticed an EVA View of related content was not updating when new nodes were added or existing nodes were edited or removed. The View was using a cache tag based caching approach, so the node_list cache context should have been invalidated whenever a node was altered.

I guessed that the View was being cached correctly, but that EVA wasn't passing the cache metadata to the node, so the page cache wasn't being invalidated when a node was altered.

Proposed resolution

Changing

$element = $view->executeDisplay($info['display']);

in eva_entity_view() to:

$element = $view->buildRenderable($info['display']);

Results in the cache metadata being included as part of the renderable array, and this fixes my issue.

Before:

No cache metadata is included in the renderable array

After:

The cache metadata has now been included

Relevant docs

https://api.drupal.org/api/drupal/core%21modules%21views%21src%21ViewExe...

Builds the render array outline for the given display.

This render array has a #pre_render callback which will call ::executeDisplay in order to actually execute the view and then build the final render array structure.

https://api.drupal.org/api/drupal/core%21modules%21views%21src%21ViewExe...

Comments

Phil Wolstenholme created an issue. See original summary.

Phil Wolstenholme’s picture

msmithcti’s picture

Status: Active » Needs review
ahebrank’s picture

Thanks, the caching scope definitely needs to be added one way or another. Looking for feedback on whether using buildRenderable causes trouble for anyone and whether any cruft can be removed as a consequence of this change.

ahebrank’s picture

I've taken a look this morning and the only end-to-end differences I see are the addition of the views' config:* and node_list cache tags to page headers. I'm inclined to merge this to dev ASAP but will keep under review for testing for a few more days.

  • ahebrank authored 8709be1 on 8.x-1.x
    Issue #2843000 by phil-wolstenholme: bubble the view cache tags to the...
ahebrank’s picture

Status: Needs review » Fixed

Merged to dev to get some more visibility. Thanks again.

ahebrank’s picture

In 8.x-1.1-rc1 release

ahebrank’s picture

Status: Fixed » Closed (fixed)