Skip to content

[HttpKernel] Remove _path from query parameters when fragment is a subrequest #17595

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

Merged
merged 1 commit into from
Mar 3, 2016

Conversation

cmenning
Copy link

Q A
Bug fix? Yes
New feature? No
BC breaks? No
Deprecations? No
Tests pass? Yes
Fixed tickets
License MIT
Doc PR

Prior to 2.3.29, all requests to the ESI fragment path ("/_fragment" by default) would have the "_path" query parameter removed. This held true whether an external proxy (such as Varnish) handled the request as true ESI, or whether the Symfony kernel was mocking ESI behavior and inlining the subrequest.

Once the "_controller" check was added in 2.3.29, the "_path" query parameter was only removed on master requests (such as those coming from an external proxy) and not subrequests, leading to differing behavior in production and development settings.

@stof
Copy link
Member

stof commented Jan 28, 2016

We need a test reproducing this.

@stof
Copy link
Member

stof commented Jan 28, 2016

And this seems the wrong fix IMO. the right fix would be to avoid generating _path in the query string when setting a controller directly

@cmenning
Copy link
Author

The alternative would be patching \Symfony\Component\HttpKernel\Fragment\RoutableFragmentRenderer::generateFragmentUri to not append the "_path" to the generated URI, but I'm not sure what other impact that would have downstream when handling the subrequest.

@cmenning
Copy link
Author

The more I look at it, the more I think this is the appropriate fix. "_path" is in the query string specifically for the FragmentListener to parse; once it's been parsed, it's removed from the ParameterBag.

It makes sense to remove it when finished with the listener, whether we use it or not, in order to keep behavior consistent.

Suppressing "_path" during generation has a higher likelihood of side effects, and would make the generation code more complex: generateFragmentUri() then has to know whether the URI is intended to be consumed by a genuine ESI/Hinclude request, or whether it's being inlined.

@fabpot
Copy link
Member

fabpot commented Mar 2, 2016

@cmenning Will you be able to add a test?

@cmenning
Copy link
Author

cmenning commented Mar 2, 2016

@fabpot Tests added.

…request attributes are already set

Added tests for _path removal in FragmentListener
@fabpot
Copy link
Member

fabpot commented Mar 2, 2016

👍

@stof
Copy link
Member

stof commented Mar 3, 2016

👍

Status: reviewed

@fabpot
Copy link
Member

fabpot commented Mar 3, 2016

Thank you @cmenning.

@fabpot fabpot merged commit c374420 into symfony:2.3 Mar 3, 2016
fabpot added a commit that referenced this pull request Mar 3, 2016
…ent is a subrequest (cmenning)

This PR was merged into the 2.3 branch.

Discussion
----------

[HttpKernel] Remove _path from query parameters when fragment is a subrequest

| Q             | A
| ------------- | ---
| Bug fix?      | Yes
| New feature?  | No
| BC breaks?    | No
| Deprecations? | No
| Tests pass?   | Yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Prior to 2.3.29, all requests to the ESI fragment path ("/_fragment" by default) would have the "_path" query parameter removed. This held true whether an external proxy (such as Varnish) handled the request as true ESI, or whether the Symfony kernel was mocking ESI behavior and inlining the subrequest.

Once the "_controller" check was added in 2.3.29, the "_path" query parameter was only removed on master requests (such as those coming from an external proxy) and not subrequests, leading to differing behavior in production and development settings.

Commits
-------

c374420 Remove _path from query parameters when fragment is a subrequest and request attributes are already set Added tests for _path removal in FragmentListener
@cmenning cmenning deleted the fragment-path branch March 3, 2016 16:16
@fabpot fabpot mentioned this pull request Mar 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants