8000 getQueryString in a forwared request returns the query-string from the original request · Issue #16169 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

getQueryString in a forwared request returns the query-string from the original request #16169

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

Closed
denisvmedia opened this issue Oct 7, 2015 · 2 comments

Comments

@denisvmedia
Copy link

Is it an expected behavior: in a controller that receives a request from the other controller using a forward() call, calling $request->getQueryString() returns the original query-string? (Request $request is injected as an argument in the controller action definition).

As a workaround I had to replace $request->getQueryString() with http_build_query($request->query->all()).

@rpg600
Copy link
Contributor
rpg600 commented Oct 7, 2015

I think this it is a normal behavior: when you forward a request you actually duplicate the master request which is based on the php globals and do a sub request which is not, so you will have the same $_SERVER variable.
An easy solution is to call the method overrideGlobals() on the sub request which overrides the php globals according to the request parameters (and updates the query string in the server bag).

@jakzal
Copy link
Contributor
jakzal commented Oct 13, 2015

This is a common problem related to mutability of the request class. See #6406.

@jakzal jakzal closed this as completed Oct 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0