Wrong cache contexts on the switcher block

Created on 26 February 2025, 3 months ago

Problem/Motivation

The language switcher cacheability has been modified here:
https://git.drupalcode.org/project/lang_dropdown/-/compare/8.x-2.1...8.x...

However the cache contexts provided in the build are not taken into account / overridden by the getCacheContexts() implementation of the block.

As a result the block does not properly vary between url context, and language options are inconsistent with the current url.

Steps to reproduce

  • Update to 8.x-2.1
  • Install more than one language
  • Publish home page in all languages
  • Publish another page only for one language
  • Enable page cache
  • Visit the website as anonymous, beginning by the start page: language switcher dropdown option will contains all the languages
  • Browse to the other page: Language switcher dropdown remains unchanged
  • Select an option not translated: Error displays

Proposed resolution

Use the getCacheContexts method instead of the build to define the proper cache contexts.

Remaining tasks

  • ✅ File an issue
  • ➖ Addition/Change/Update/Fix
  • ➖ Merge request, Patch, or Commit
  • ➖ Testing to ensure no regression
  • ➖ Automated unit testing coverage
  • ➖ Automated functional testing coverage
  • ➖ UX/UI designer responsibilities
  • ➖ Readability
  • ➖ Accessibility
  • ➖ Performance
  • ➖ Security
  • ➖ Documentation
  • ➖ Code review by maintainers
  • ➖ Full testing and approval
  • ➖ Credit contributors
  • ➖ Review with the product owner
  • ➖ Release notes snippet
  • ❌ Release

User interface changes

  • N/A

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • N/A
🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇫🇷France GuillaumePacilly

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