🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@yoeunes
Copy link
Contributor

@yoeunes yoeunes commented Nov 21, 2025

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues -
License MIT

When using name_prefix on an import, RouteCollection::addNamePrefix() unconditionally prefixes the target of all aliases.
If an alias points to an external route (a route not present in the imported collection), the link breaks because the external route name is not actually changed.

This PR ensures we only prefix the alias target if that target exists within the collection being modified.

# config/routes.yaml
admin_section:
    resource: routes/admin.yaml
    prefix: /admin
    name_prefix: admin_

Inside routes/admin.yaml, I have an alias pointing to a global route defined elsewhere (app_logout):

# config/routes/admin.yaml
logout:
    alias: app_logout

Before:
php bin/console cache:clear fails because the dumper tries to find the prefixed target (admin_app_logout) which does not exist:

In CompiledUrlGeneratorDumper.php line 72:
Target route "admin_app_logout" for alias "admin_logout" does not exist.

After:
The alias correctly points to the original app_logout route and the cache warms up successfully:

[OK] Cache for the "dev" environment (debug=true) was successfully cleared.

@nicolas-grekas
Copy link
Member

Thank you @yoeunes.

@nicolas-grekas nicolas-grekas merged commit 9bc8d60 into symfony:6.4 Nov 21, 2025
11 checks passed
This was referenced Nov 21, 2025
This was referenced Dec 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants