Problem/Motivation
On Drupal 11.3.10, switching language via the dropdown_language block redirects to the first visited page(after cache clear) instead of the current page in the selected language.
- #2232375: Support CacheOptionalInterface in BlockViewBuilder, use it in language switcher block to prevent max-age 0 bubbling
- Change record #3554070: Block plugins implementing CacheOptionalInterface will not have their own render cache entries
Proposed resolution
The fix is to implement CacheOptionalInterface on the DropdownLanguage block class, identical to how Drupal core's own LanguageBlock was updated in https://www.drupal.org/project/drupal/issues/2232375, so that cache keys are never assigned and the block always renders fresh with the correct current page URL.
Drupal core's own LanguageBlock:
https://git.drupalcode.org/project/drupal/-/blob/11.3.11/core/modules/la...
Issue fork dropdown_language-3593252
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
cbuvaneswaran commentedHi,
I updated the CacheOptionalInterface logic same as core language switcher block. Please validate the MR and merge.
https://git.drupalcode.org/project/dropdown_language/-/merge_requests/38
Regards,
Buvaneswaran
Comment #4
skaughtComment #5
skaughtComment #6
skaughtComment #7
kieran.cottI've added test coverage for the above changes in MR 38, and addressed the remainder of the pipeline failures in the linked issue.
Comment #8
kieran.cottI've pulled in the newly merged changes from #3593003 and made a couple of additional tweaks - pipelines on MR 38 now pass.
Comment #9
skaught@kieran.cott. -- awesome!
i'll be taking this in shortly..
Comment #11
skaughtComment #12
skaughtComment #14
skaughtComment #16
kieran.cottThanks for merging @skaught - now this is fixed, would you be able to review assigned contributions?
Comment #17
skaughtcheers