Path processed Urls have no corresponding route

Created on 9 August 2024, 4 months ago
Updated 20 August 2024, 4 months ago

In 2.0.6, an exception was raised in \Drupal\easy_breadcrumb\TitleResolver::getTitle() if the Url is unrouted (e.g. for instance for a page whom Url was processed by a custom InboundPathProcessor). The title resolver tried to get the route name of an unrouted Url.

This was fix in 2.0.7 with a try/catch statement but we do not return anything if there's an exception.

This leads to broken breadcrumb parts.

We should returns the parent::getTitle() method for unrouted Urls.

How to test:

  • Create a custom path processor (e.g. path_processor_inbound)
  • Rewrite any given path to something else which does not correspond to any existing route
  • Load the page on frontend with an EasyBreadcrumb block placed

Result in 2.0.6:

UnexpectedValueException: base:my/fake/route has no corresponding route. in Drupal\Core\Url->getRouteName() (line 567 of core/lib/Drupal/Core/Url.php).
Drupal\easy_breadcrumb\TitleResolver->getTitle(Object, Object) (Line: 755)
Drupal\easy_breadcrumb\EasyBreadcrumbBuilder->getTitleString(Object, Object, Array) (Line: 530)
Drupal\easy_breadcrumb\EasyBreadcrumbBuilder->build(Object) (Line: 83)
Drupal\Core\Breadcrumb\BreadcrumbManager->build(Object) (Line: 73)

Result in 2.0.7:
It works but the breadcrumb parts are not resolved and you see something like `Home > my > fake > route > current`

Attached MR fix the issue.

🐛 Bug report
Status

Closed: works as designed

Version

2.0

Component

Code

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