User warning: Trying to overwrite a cache redirect with one that has nothing in common, old one at address

Created on 8 January 2025, 16 days ago

Problem/Motivation

After updating from Drupal 10.3 to 10.4 this error emerged:

User warning: Trying to overwrite a cache redirect with one that has nothing in common, old one at address "languages:language_interface, theme, user.permissions" was pointing to "url.path.parent, url.path.is_front, route", new one points to "url.path, languages:language_url". in Drupal\Core\Cache\VariationCache->set() (line 138 of core/lib/Drupal/Core/Cache/VariationCache.php).

Steps to reproduce

No other actions beyond the update.

Proposed resolution

Apparently the cache context in the BreadcrumbBuilder needs to be enhanced. At least this appears to solve the problem in my case.

In BreadcrumbBuilder.php line 227 this row

$breadcrumb->addCacheContexts(['url.path']);

needs to be replaced by this:

$breadcrumb->addCacheContexts([
    'url.path', 
    'languages:language_url', 
    'languages:language_interface', 
    'theme', 
    'user.permissions',
    'url.path.parent',
    'url.path.is_front',
    'route'
]);

Remaining tasks

Review suggestion and update the code.

๐Ÿ› Bug report
Status

Active

Version

1.1

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ชIreland marksmith

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024