Affected by core regression issue on no route match?

Created on 21 March 2023, over 1 year ago
Updated 3 April 2023, over 1 year ago

Postponed on 🐛 [regression] Language switcher block throws exception when no route is matched Fixed

Problem/Motivation

This is a follow-up on 🐛 Incorporate Drupal 9.4 core changes to getLanguageSwitchLinks Fixed to track changes in core.

I just saw 🐛 [regression] Language switcher block throws exception when no route is matched Fixed and the lines of code are very similar to the ones in this module:

-    $links = $this->languageManager->getLanguageSwitchLinks($type, Url::fromRouteMatch(\Drupal::routeMatch()));
+    $route_match = \Drupal::routeMatch();
+    // If there is no route match, for example when creating blocks on 404 pages
+    // for logged-in users with big_pipe enabled using the front page instead.
+    $url = $route_match->getRouteObject() ? Url::fromRouteMatch($route_match) : Url::fromRoute('<front>');
+    $links = $this->languageManager->getLanguageSwitchLinks($type, $url);

I didn't run into it yet myself, but I guess our implementation here should be aligned to the one in core?

Did anyone experience this issue?

Steps to reproduce

TBD!

Proposed resolution

Fix the implementation in this issue like core does

Remaining tasks

- Monitor the core isse
- Make changes accordingly
- Carry over tests

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Postponed

Version

4.0

Component

Code

Created by

🇩🇪Germany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024