#3631129 DomainSourcePathProcessor treats <current> as the route of the path since Drupal 11.4

Closes #3631129.

Since Drupal 11.4, the URL generator passes the route name to outbound path processors. For a URL built from <current> (pagers, language switcher links, #ajax URLs), that name stays <current>, while the route object and the parameters are those of the page being viewed. <current> names no real route, so none of the processor's filters can match it: the excluded route names, the link-template exclusions and the entity. check all see <current> instead of the real route, and so do the alter hooks.

Changes

  • DomainSourcePathProcessor::getRouteName() returns the current route's name for <current>, and the route name passed by the generator otherwise. The exclusion check and the entity lookup use it, so <current> URLs are filtered like URLs built from the named route. $options['route_name'] is left untouched for later processors and the alter hooks.
  • current_route_match is injected (the class is @internal and autowired). It only reads the route the kernel already matched: no route matching, no query.

Tests

DomainSourceCurrentRouteTest (kernel) makes a node page the current route and builds URLs through the real URL generator:

  • on entity.node.canonical, a <current> URL goes to the node's source domain, like the named route. Fails without the fix ('/node/1');
  • on entity.node.edit_form with edit_form excluded, a <current> URL stays on the active domain. It fails if the exclusion check reads $options['route_name'] while the entity lookup reads the real name.

Locally: all domain kernel classes pass on SQLite, the new class on MySQL; phpcs and phpstan clean.

Backports to 3.x and 3.0.x follow (3.0.x without a constructor change).

AI-Generated: Yes (Claude Code was used to help write the fix, its test and this description. I reviewed them, and the canonical-page test was confirmed to fail without the fix and to pass with it.)

Edited by Frank Mably

Merge request reports

Loading
Loading