Variation cache error when enabling the "domain"-module.

Created on 23 May 2025, 14 days ago

Problem/Motivation

When enabling the "Domain"-module, I seem to run into this error:

The complete set of cache contexts for a variation cache item must contain all of the initial cache contexts, missing: user.site

I saw in the cache contexts that the exact ones listed in the default value of the container parameter `render.config:required_cache_contexts` were used, but when looking at the NavigationRenderer, they're hardcoded into it.
If I replace the hardcoded contexts list on line 133 in the NavigationRenderer:

$build[$delta]['#cache']['contexts'] = ['user.permissions', 'theme', 'languages:language_interface'];

With this code:

$renderer_config = \Drupal::getContainer()->getParameter('renderer.config');
$build[$delta]['#cache']['contexts'] = $renderer_config['required_cache_contexts']
  ?? ['user.permissions', 'theme', 'languages:language_interface'];

Then it seems to work (since I've added `user.list` as a required context in my services file).

Steps to reproduce

- Start on an empty Drupal 11 website
- Enable the Navigation and Domain modules

Proposed resolution

I think, using the container parameter renderer.config:required_cache_contexts instead of the hardcoded list:
- user.permissions
- theme
- languages:language_interface

Should be fine? Unless I completely misunderstand this functionality.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇧🇪Belgium RandalV

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

Comments & Activities

Production build 0.71.5 2024