Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[FrameworkBundle] keep query in redirect#26281
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
c8c18f2 toa400739Compare5fe9639 to5f3b11eCompare| * @param string $route The route name to redirect to | ||
| * @param bool $permanent Whether the redirection is permanent | ||
| * @param bool|array $ignoreAttributes Whether to ignore attributes or an array of attributes to ignore | ||
| * @param bool $keepRequestMethod Wheter redirect action should keep HTTP request method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Should probably be fixed on 2.7 instead, see#25859 in progress
| $controller =newRedirectController($router); | ||
| $returnResponse =$controller->redirectAction($request,$route,$permanent,$ignoreAttributes,$keepRequestMethod); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
to revert
5f3b11e tob6a2af3CompareSimperfit commentedMar 2, 2018
This PR is rdy. |
nicolas-grekas left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
with minor comments
| $attributes =array(); | ||
| if (false ===$ignoreAttributes ||is_array($ignoreAttributes)) { | ||
| $attributes =$request->attributes->get('_route_params'); | ||
| $routeParams =$request->attributes->get('_route_params'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'd suggest keeping the name $attributes, it's still valid and will reduce merge conflicts
on the next line, no need for the\ in front of array_merge
| if (false ===$ignoreAttributes ||is_array($ignoreAttributes)) { | ||
| $attributes =$request->attributes->get('_route_params'); | ||
| $routeParams =$request->attributes->get('_route_params'); | ||
| $attributes =$keepQueryParams ?\array_merge($request->query->all(),$routeParams) :$routeParams; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I suggest adding a test ensuring that attributes coming from_route_params still win over attributes coming from the query string when merging them together.
| $request->query =newParameterBag(array('base' =>'zaza')); | ||
| $request->attributes =newParameterBag(array('_route_params' =>array())); | ||
| $urlGenerator =$this->getMockBuilder(UrlGeneratorInterface::class)->getMock(); | ||
| $urlGenerator->expects($this->any())->method('generate')->will($this->returnValue('/test?base=zaza')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
this does not test anything, as you don't assert arguments received by the router. Try to run your test on the unpatched codebase of the controller, and you will see that it will pass too.
Simperfit commentedMar 26, 2018
@stof done. |
b6a2af3 to406bfc9CompareSimperfit commentedMar 26, 2018
Status: Needs Review |
fabpot commentedMar 27, 2018
Thank you@Simperfit. |
This PR was merged into the 4.1-dev branch.Discussion----------[FrameworkBundle] keep query in redirect| Q | A| ------------- | ---| Branch? | 4.1| Bug fix? | no| New feature? | yes <!-- don't forget to update src/**/CHANGELOG.md files -->| BC breaks? | no <!-- seehttps://symfony.com/bc -->| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->| Tests pass? | yes <!-- please add some, will be required by reviewers -->| Fixed tickets |#26256 <!-- #-prefixed issue number(s), if any -->| License | MIT| Doc PR |#9314<!--Write a short README entry for your feature/bugfix here (replace this comment block.)This will help people understand your PR and can be used as a start of the Doc PR.Additionally: - Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the master branch.-->Commits-------406bfc9 [FrameworkBundle] keep query params in redirection
Uh oh!
There was an error while loading.Please reload this page.