Problem/Motivation

When an internal link that is not an entity is added to the menu using "internal:" as URL, it results in "UnexpectedValueException: External URLs do not have internal route parameters. in Drupal\Core\Url->getRouteParameters()"

Steps to reproduce

Enable "admin_toolbar_links_access_filter" module on Drupal 9.5.9. Add a menu link to one of the menu item using a custom module and the url being "internal:" on your custom module's liks.menu.yml

Proposed resolution

Check if the URL is routed before retrieving routed parameters.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

dsrikanth created an issue. See original summary.

dsrikanth’s picture

StatusFileSize
new965 bytes

Updating the path in the patch file.

dsrikanth’s picture

StatusFileSize
new1.05 KB

  • adriancid committed 34a36d82 on 3.x authored by dsrikanth
    Issue #3363941 by dsrikanth, adriancid: Internal unrouted URLs results...
adriancid’s picture

Status: Needs review » Fixed

Thanks

nicholass’s picture

I can confirm our site hit this issue and the patch solved it. Only affected non-admin users. You could test it by masquerading as them. We had a manually created link pointing to a redirect in the menu.

Status: Fixed » Closed (fixed)

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

saltwaterskin’s picture

Shouldn't this line
if ($url->isExternal() || !$original_link->getUrlObject()->isRouted()) {
be this instead?
if ($url->isExternal() || !$url->isRouted()) {
$original_link would not be set on line 83 if I am reading this correctly

nicholass’s picture

@saltwaterskin I think you are correct, I guess the $url->isExternal() is true so it was never getting to that second option.