noodlehaus/dispatch

Collision between route parameters and query string parameters

nmcgann opened this issue · 1 comments

If a route defined like "/edit/:aval" has a query string parameter with the same name as the named parameter then the query string parameter is overwritten by the route parameter.

e.g. with the example above if the URI is /edit/1234?aval=5678 then a call to param('aval') returns 1234 as the QSP of the same name with value 5678 is overwritten.

Problem originates in the param() function called in the on() function:

 // used by on() for merging in route symbols.
$source = array_merge($source, $name);

The merge overwrites GET/POST symbols with the same key name.
(I added a separate rparam() function in my application and kept the route params completely separate to GET/POST)
If this limitation is intentional then it would be useful to add a note in the user guide warning people to choose non-colliding names.

Sorry for this confusion, but yes, it is an intended behavior, which was copied from other frameworks.

Will update the documentation with this clarification. I'm actually hinting for a pull request ;)

Thanks for raising this :)