Twig function Path() returns RouteNotFoundException if route does not exists

Created on 22 February 2019, almost 6 years ago
Updated 8 November 2024, about 2 months ago

Path() is a twig function which is used to generate a relative url path of the given route name. In case if route name does not exist or invalid, it returns an following exception:

The website encountered an unexpected error. Please try again later.Symfony\Component\Routing\Exception\RouteNotFoundException: Route "[ROUTE_NAME]" does not exist.

How to Reproduce.

  • use function path() in a twig file and pass a route_name and parameters in path() function
  • Now uninstall module that define route_name which is passed in path() twig function.
  • Reload Drupal page which load twig file where path() function is called.
  • Now you can see RouteNotFoundException

Proposed Solution

Path() function should return empty string or NULL if module that define route_name is not enabled.

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component

theme system

Created by

πŸ‡ͺπŸ‡ΈSpain himanshu5050 Spain

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024