Problem/Motivation

A TypeError occurs when attempting to resolve the page title for breadcrumbs.
The error is caused by $route_match->getRouteObject() returningNULL, whileTitleResolver::getTitle() expects a valid Route object.

TypeError: Drupal\Core\Controller\TitleResolver::getTitle(): Argument #2 ($route) must be of type Symfony\Component\Routing\Route, null given, called in /var/www/html/web/themes/contrib/bootstrap3/src/Plugin/Preprocess/Breadcrumb.php on line 45 in Drupal\Core\Controller\TitleResolver->getTitle() (line 50 of /var/www/html/web/core/lib/Drupal/Core/Controller/TitleResolver.php)

Steps to reproduce

  1. Enable Breadcrumb from the theme settings
  2. Visit any 404 page

Proposed resolution

  1. Add null check for the route object.
  2. Verify breadcrumb rendering works without errors in all contexts.
  3. Test on pages with and without valid routes.

Issue fork bootstrap3-3557071

Command icon 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

madelyncruz created an issue. See original summary.

madelyncruz’s picture

Title: TypeError: Drupal\Core\Controller\TitleResolver::getTitle(): Argument #2 ($route) must be of type Symfony\Component\Routing\Route, null given » TypeError: Drupal\Core\Controller\TitleResolver::getTitle(): Argument #2 ($route) must be of type Symfony\Component\Routing\Route, null given in breadcrumb title
Issue summary: View changes

madelyncruz’s picture

Assigned: madelyncruz » Unassigned
Status: Active » Needs review
mably’s picture

Hi @madelyncruz, can you give us a bit more details on how to reproduce the problem? Haven't been able to reproduce it locally.

  • mably committed ac5a196f on 2.0.x authored by madelyncruz
    fix: #3557071 TypeError: Drupal\Core\Controller\TitleResolver::getTitle...
mably’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.