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
[router] Does not take additional GET parameter in account if it has a default value. #18035
Comments
Does this only happen if both routes are configured for the same path? |
No, that's just to show the bug. It is always so. |
… default has value
… default value is set
… default value is set
… default value is set
… default value is set
I would say that's a normal behavior. The second argument of the |
I don't think it's normal. Default means value when not defined. And when I enter an url with ?p=2 manually, the controller receives 2. So this can not be intended by url generating and not when it retrives the parameter value. |
… default is provided
… default is provided
… default is provided
… default is provided
… default is provided
… default is provided
… default is provided
… default is provided
… default is provided
… default is provided
It's weird because That being said, I would agree it's a bug - though really edge-case. The intention is that if there is no wildcard to fill in, the extra parameters are added as query parameters. In this case, the first route has no But again, it's weird :). You would fetch the Btw @Alsatian67 thanks for the very clear report and fork - it's a weird situation, but very easy to understand! |
Duplicate of #10940 |
Let me explain my usage : It's a search page with many optional parameters : ?page=1&name=&sortby=&date=&category= ... Each of them are optional and mostly not used. So I don't like a route like /{page}/{name}/{sortby} ... But I want to set defaults like page = 1, name = "", sortby = "name" ;) |
…lt (Tobion) This PR was merged into the 2.3 branch. Discussion ---------- [Routing] add query param if value is different from default | Q | A | ------------- | --- | Branch? | 2.3 | Bug fix? | yes | New feature? | yes | BC breaks? | most likely not | Deprecations? | no | Tests pass? | no | Fixed tickets | #10940, #18111, #18035 | License | MIT | Doc PR | - Commits ------- 1ef2edf [Routing] add query param if value is different from default
In a Controller, I have two actions :
In twig, I generate routes to these actions with an additional GET parameter 'p' :
Result :
The first one, totally ignore the value assigned on 'p'.
Bug reproduced here :
https://github.com/Alsatian67/symfony-standard
(index page shows the two paths)
The text was updated successfully, but these errors were encountered: