Skip to content
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

[HttpFoundation] Request::getPathInfo() inconsistencies #10478

Closed
carlescliment opened this issue Mar 18, 2014 · 4 comments
Closed

[HttpFoundation] Request::getPathInfo() inconsistencies #10478

carlescliment opened this issue Mar 18, 2014 · 4 comments

Comments

@carlescliment
Copy link

I'm having some problems trying to modify a request in order to dinamically accept aliases without having to explicitly define the routes. Probably I'm not doing it right, but the problem leads me to think that there is something inconsistent in the Request class.

if I do this:

$request = Request::createFromGlobals();
$request->server->set('REQUEST_URI', '/my-path');
$path = $request->getRequestUri();

Then $path is /my-path.

But if I do:

$request = Request::createFromGlobals();
$request->getRequestUri();
$request->server->set('REQUEST_URI', '/my-path');
$path = $request->getRequestUri();

Then $path is the original path and not /my-path.

I think it is a strange behaviour, it is error-prone and makes you take wrong assumptions.

@carlescliment carlescliment changed the title Request::getPathInfo() inconsistencies [HttpFoundation] Request::getPathInfo() inconsistencies Mar 18, 2014
@Tobion
Copy link
Member

Tobion commented Mar 18, 2014

It's because the getter caches the result, so modiying the ServerBag afterwards has no effect. I added this observation to #6406

@carlescliment
Copy link
Author

Thanks for the link, @Tobion. Sad to read that it won't be fixed until 3.*.

I finally managed to bypass the problem by extending the Request class and adding a method to clear the cached attributes.

@carlescliment
Copy link
Author

Closing the issue since it was already noticed.

@Tobion
Copy link
Member

Tobion commented Mar 18, 2014

The reason it probably has to wait for version 3 is that it is a highly used class we don't want to break BC and we need to fix some things from groud up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants