-
Notifications
You must be signed in to change notification settings - Fork 29
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
Route conflicts #187
Comments
@oliverklee That's enlightening, thanks. |
I've conducted more research and done some testing. Symfony itself does not "notice" if there are two routes with the same URL (or two different patterns that will resolve to the same URL, or two patterns that will match the same URLs in some cases). It just goes through all routes and takes the first once that matches the current request URL. So, in theory, we could write something like a route linter that goes through all routes and at least warns the patterns are exactly the same. To test whether two different patterns are equivalent, we would need to construct once deterministic finite automaton for each patterns and then test those for equivalence. This is possible, but PSPACE-complete, i.e., quite a lot of work (see https://cs.stackexchange.com/questions/12267/algorithm-to-determine-whether-two-regexes-are-equivalent and https://en.wikipedia.org/wiki/PSPACE-complete). So doing any automatic checking is not feasible. What we could do is that we require the prefix option being set in each route configuration in the composer.json and then throw an error if two routes have the same prefix. This will not prevent prefixes that are prefixes of other prefixes (e.g., "api/v2/" and "/" as for the REST API and the web frontend (planned)), though. @samtuke What do you think of this? |
@oliverklee It sounds like the composer.json / prefix approach is the best or only technical option currently identified, and yet it would not protect the most important routes from being overridden. |
Agreed. |
@samtuke, I've done some testing and some research on representing conflicts for phpList modules that provide the same routes (e.g., "/" or "/api/v2/"):
I've come to the conclusion that the risk of conflicting routes is relatively low anyway, and by properly using the dependencies, the official route "wins". So I'd like to not add any additional conflict mechanism, if there are no objections. @samtuke, @michield, any opinions on this?
The text was updated successfully, but these errors were encountered: