BlockContentBlock does not inherit block content entity cacheable dependency

Created on 5 August 2024, 5 months ago
Updated 8 August 2024, 5 months ago

Problem/Motivation

After creating a block content placed in the block overview, if the block is rendered and then the block content is edited, the block render cache is not invalidated.

Steps to reproduce

  1. Create and place the block content in a region using the block layout.
  2. Render the page where the block is placed to ensure it is cached.
  3. Edit the block content.
  4. Re-render the page and observe that the block content has not been updated.

Proposed resolution

Merge the cache contexts, tags and max age of the block content block with the loaded block content entity (from getEntity).

  /**
   * {@inheritdoc}
   */
  public function getCacheContexts() {
    $contexts = parent::getCacheContexts();
    if (($entity = $this->getEntity()) && $entity instanceof BlockContentInterface) {
      $contexts = Cache::mergeContexts($contexts, $entity->getCacheContexts());
    }
    return $contexts;
  }
  ...

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
Block contentΒ  β†’

Last updated 20 days ago

Created by

πŸ‡«πŸ‡·France xavier.masson Haute-Normandie

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024