InvalidArgumentException thrown on 404 pages with BigPipe module and language switcher block

Created on 16 March 2023, almost 2 years ago
Updated 18 March 2023, almost 2 years ago

Problem/Motivation

An error appears if the language switcher block is enabled, BigPipe module is installed, and a user visits a nonexistent (404) page: InvalidArgumentException: Route required in Drupal\Core\Url::fromRouteMatch() (line 170 of core/lib/Drupal/Core/Url.php).

Apparently when BigPipe renders the block, the current route is undefined in the case of 404 pages, so Url::fromRouteMatch() throws an InvalidArgumentException.

Steps to reproduce

Place the language switcher block, enable BigPipe module and visit a nonexistent (i.e. 404) page. The error message will be logged, and will also appear on the page if error messages are configured to be displayed.

Proposed resolution

We could check if there is currently a route object before trying to generate the URL. But this means the block will not render switch links on 404 pages if BigPipe is installed, but will render them if it's not installed. So this isn't a very good resolution.

Remaining tasks

Hopefully someone comes up with a different patch such that the block is rendered the same way with or without BigPipe module. I'm just offering this patch as proof of concept.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

πŸ› Bug report
Status

Closed: duplicate

Version

10.1 ✨

Component
Language moduleΒ  β†’

Last updated 6 days ago

  • Maintained by
  • πŸ‡©πŸ‡ͺGermany @sun
Created by

πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

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

Comments & Activities

Production build 0.71.5 2024