PageDisplayVariant does not transmit cache metadata

Created on 10 November 2025, 15 days ago

Problem/Motivation

Core has 2 PageDisplayVariant plugins, those 2 plugins does not inject the cacheable metadata into the returned build array.

In app/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php, the PageDisplayVariantSelectionEvent event are injected into the plugin instance:

// Instantiate the page display, and give it the main content.
      $page_display = $this->displayVariantManager->createInstance($variant_id, $variant_configuration);
      ...
      $page_display
        ...
        ->addCacheableDependency($event);

But then in core/modules/block/src/Plugin/DisplayVariant/BlockPageVariant.php and core/lib/Drupal/Core/Render/Plugin/DisplayVariant/SimplePageVariant.php there is no usage of those cache metadata in the build method.

Steps to reproduce

In the related issue we witnessed the problem when needing to inject a cache tag in the event for cache invalidation.

Proposed resolution

Inject cache metadata in the build method.

Remaining tasks

Provide MR
Provide test

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

block.module

Created by

🇫🇷France Grimreaper France 🇫🇷

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.

No activities found.

Production build 0.71.5 2024