Incorrect cache contexts

Created on 21 March 2024, 3 months ago

Problem/Motivation

Blocks rendered in the tab with content that depends on taxonomy terms causes the first cached term to be displayed on all the pages.

Steps to reproduce

Create a block that depends on a specific vocabulary term
Create multiple taxonomy terms from the same vocabulary
Create a tab block
Open the first term correct results is shown
Open the second term cached result for first term is shown

Proposed resolution

Blocktabs{
  ...
  public function getCacheContexts() {
    $contexts = parent::getCacheContexts();
    foreach ($this->getTabs() as $tab) {
      $contexts = Cache::mergeContexts($tab->getCacheContexts());
    }
    return $contexts;
  }
...

The existing code uses
$contexts = Cache::mergeContexts($tab->getContexts());
Should be changed to
$contexts = Cache::mergeContexts($tab->getCacheContexts());

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

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

Comments & Activities

Production build 0.69.0 2024