[HttpKernel] Fix issue when no query parameter with mapQueryString#51036
[HttpKernel] Fix issue when no query parameter with mapQueryString#51036AurelienPillevesse wants to merge 1 commit intosymfony:6.3from AurelienPillevesse:fix-map-query-string-when-no-query-parameters
Conversation
|
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
|
You should write the argument this way instead: #[MapQueryString] HelloGetRequest $helloGetRequest = new HelloGetRequest() |
|
Thanks for the reply @nicolas-grekas, it might be interesting to add this information somewhere in the documentation to share the knowledge. |
|
You're right. Can you please consider a PR to the doc? |
@nicolas-grekas While I understand that it can be solved on the user's end, I can't imagine why anyone would want the route with query params to give a 404 error when there are no query parameters. Query parameters are always optional. If the issue isn't going to be fixed, then developers should provide a default value for all the routes using #[MapQueryString]. Which is easy to forget (but can be solved by new static analysis rules) |
|
See also #50690 (comment) But there are too many comments on this topic scattered on closed issues. On my side, I see no issues with |
If I call the URL
http://localhost:8080/hello, I will receive a 404 Not Found error because there is nothing in the query parameters.The idea is to have the object
HelloGetRequestinitialized to access it and if I try to get$helloGetRequest->dateDebut,nullwill be displayed.