Problem/Motivation

If some cases a WPOD appears if corresponding route is found for a node with menu entry.

UnexpectedValueException: base:de/sport has no corresponding route
#0 /var/www/www.krefeld.de/docroot/modules/contrib/etracker/etracker.module(334): Drupal\Core\Url->getRouteName()
#1 /var/www/www.krefeld.de/docroot/modules/contrib/etracker/etracker.module(374): _etracker_set_default_variables()
#2 /var/www/www.krefeld.de/docroot/modules/contrib/etracker/etracker.module(206): _etracker_add_variable()
#3 /var/www/www.krefeld.de/docroot/core/lib/Drupal/Core/Extension/ModuleHandler.php(552): etracker_page_attachments_alter()

Steps to reproduce

  1. create a menu entry in main menu manually: Paste /de/alias in the link field
  2. create a page with a menu entry and set the lately created menu entry as parent
  3. See the WPOD

Proposed resolution

I think there anywhere some defense needed to avoid the WPOD for the end user.

Issue fork etracker-3572877

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

sunlix created an issue. See original summary.

nickolaj made their first commit to this issue’s fork.

nickolaj’s picture

Status: Active » Needs review

Added `Url::isRouted()` check before calling `getRouteName()` in `_etracker_set_default_variables()` to prevent the `UnexpectedValueException` when breadcrumb links reference unrouted URLs (e.g. manually created menu entries).

sunlix’s picture

Status: Needs review » Needs work

So yeah, that is a rabbit hole. :D
I wanted to add a functional test to test the breadcrumb as area feature at all, because we don't cover it yet.
On the track I found out, that the feature never really worked.
Some tiny adjustment seems to work, but the test do not run through stage two after altering etracker.settings.
I think we have a caching error here. Relevant caches were not invalidated after saving settings.
Caling drupal_flush_all_caches(); inside the test let the test run through, but we have to figure out, were the config cache context is needed.

sunlix’s picture

Status: Needs work » Needs review

So, I think this is now ready for the moment.

On the bigger picture the hooks should be reworked because there is some kind of dead code like preprocess_page and the logic in _etracker_add_variable and _etracker_set_default_variables is unnecessary and basically has no effect because the individualisations where done in page_attachments_alter already.

The call path is attachments_alter -> preprocess_page

What I am really worried about is, that currently no test from the main module is running in the gitlab pipeline. Only the submodule tests from cookies_etracker are running.

sunlix’s picture

Status: Needs review » Fixed

Thank you for your contribution!

For now we are good to go here. The real work awaits on #3605509: Rework default_variable handling in .module

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.

  • sunlix committed 41b2fe71 on 8.x-3.x authored by nickolaj
    fix: #3572877 WPOD if no corresponding route is found
    
    By: sunlix
    By:...

Status: Fixed » Closed (fixed)

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