You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would expect generate('book', {'page': $page}) to generate these routes:
/book when $page == 1
/book?page=2 when $page == 2
What actually happens is that when a parameter has a default value, but is not present in the route path, it just gets eaten by Symfony. Both of the above values for $page result in the path /page being generated.
The text was updated successfully, but these errors were encountered:
I had seen #5410 but not #7458 which is probably the more important PR from my point of view. Did the "fix the documentation" issue get addressed? I saw nothing that addressed this known bug (i.e. inconsistent behaviour that can't be fixed for legacy reasons).
The other option is to introduce a new function (say, make()) that does preserve query string arguments even when they have a default value. There are a few more possibilities too.
…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
Given a route like this:
I would expect
generate('book', {'page': $page})
to generate these routes:/book
when$page == 1
/book?page=2
when$page == 2
What actually happens is that when a parameter has a default value, but is not present in the route path, it just gets eaten by Symfony. Both of the above values for
$page
result in the path/page
being generated.The text was updated successfully, but these errors were encountered: