-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing] Duplicate route names silently ignored #12561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
AFAIR the last route wins. |
The order is determined by the order in which you import resources: imported resources are loaded in the place they appear in the file. |
Sorry, something went wrong.
I think the only solution would be that devs who want to overwrite routes have to add a flag |
That's why early Symfony2 docs suggested to name routes like |
@stof, could we add a log if a route is overwrite? |
@aferrandini At least, this won't work reliably when a route is overwritten in the same YAML file since the YAML parser doesn't trigger warnings on duplicate entries (see #11538). Nonetheless, it could indeed be an improvement to trigger a warning or something like that when a route will be added to a |
@xabbuh that's what I mean. |
Closing as this is how YAML works as explained by @xabbuh |
It's only possible to have one route with a given name, but it is possible for duplicate route names to go undetected because Symfony will silently ignore the issue. I believe the second one found will overwrite the first, although I guess the loading order is non-deterministic (or determined by factors that can easily change).
Given two bundles both trying to define a login route:
Only one of these routes will exist. This might be an extreme example, because usually the changed behaviour is noticeable. But for applications with many bundles or locale-specific routes, or where it's a simple content page instead of login, then it can be missed.
Usually Symfony is quite strict about configuration problems, helping to ensure they're spotted straight away. Is there a reason for the current behaviour, or can the router throw an exception when trying to overwrite a route?
The text was updated successfully, but these errors were encountered: