Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm using Bootstrap with the link_attributes module. When adding a class to an external link, a fatal error occurs:
The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">UnexpectedValueException</em>: External URLs do not have an internal route name. in <em class="placeholder">Drupal\Core\Url->getRouteName()</em> (line <em class="placeholder">583</em> of <em class="placeholder">core/lib/Drupal/Core/Url.php</em>). <pre class="backtrace">Drupal\bootstrap\Plugin\Preprocess\Menu->convertAttributes(Array) (Line: 23)
Drupal\bootstrap\Plugin\Preprocess\Menu->preprocessVariables(Object) (Line: 53)
Drupal\bootstrap\Plugin\Preprocess\PreprocessBase->preprocess(Array, 'menu', Array) (Line: 1408)
Adding a check to ensure that the link is routed prior to grabbing the route is a must here.
Comment | File | Size | Author |
---|---|---|---|
#3 | external_urls_do_not_have_internal_route_name_3089477_3.patch | 708 bytes | brooke_heaton |
Comments
Comment #2
brooke_heaton CreditAttribution: brooke_heaton commentedComment #3
brooke_heaton CreditAttribution: brooke_heaton commentedPatch adds an isRouted check on the url before grabbing a route name.
Comment #4
markhalliwellAh, great catch. Ty!
Comment #7
brooke_heaton CreditAttribution: brooke_heaton commentedWow that was fast. Thanks Mark!