8000 [FrameworkBundle] http_method_override option is ignored when app is behind HttpCache · Issue #8481 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] http_method_override option is ignored when app is behind HttpCache #8481

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
kbond opened this issue Jul 12, 2013 · 12 comments

Comments

@kbond
Copy link
Member
kbond commented Jul 12, 2013

The work around is to manually call Request::enableHttpMethodParameterOverride(); in my front controller. Is this expected?

  • 2.3.* without HttpCache: framework.http_method_override is used and works as expected
  • 2.3.* with HttpCache: framework.http_method_override is ignored
@mvrhov
Copy link
mvrhov commented Jul 12, 2013

Yes, see UPGRADE-2.2.md.
Or more detailed answer..
This shouldn't be needed on 2.3, because there is configuration option framework.http_method_override, which defaults to true

@kbond
Copy link
Member Author
kbond commented Jul 12, 2013

Yes, I see the option was added in 2.3 - that is the version I am having this issue with. I have updated the summary.

@stof
Copy link
Member
stof commented Jul 15, 2013

@mvrhov The issue with the config option is that it is used when booting the kernel, whcih means that HttpCache will not use the method override (as it boots the kernel only when it is a cache miss)

@kbond
Copy link
Member Author
kbond commented Jul 15, 2013

@stof shouldn't unsafe request methods result in a cache miss?

@kbond
Copy link
Member Author
kbond commented Jul 15, 2013

@stof nm, I think I see what the problem is.

When checking to see if the method is safe, it is calling Request->getMethod() which caches the result. Once the kernel is booted, it calls Request::enableHttpMethodParameterOverride() as expected, the next time Request->getMethod() is called it returns the initial cached result.

ref: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Request.php#L1113

@inssein
Copy link
inssein commented Jul 31, 2013

I just ran into this problem while using Sonata Admin Bundle, none of my delete actions were working because it needed $httpMethodParameterOverride to be true, but its false due to what @kbond mentioned above.

For now I have reverted to calling Request::enableHttpMethodParameterOverride(); in my app.php as done earlier here: symfony/symfony-standard@1970b83

@fabpot
Copy link
Member
fabpot commented Sep 12, 2013

Closing as the configuration is only available when the Kernel is booted, which is not the case when a request is cached.

@fabpot fabpot closed this as completed Sep 12, 2013
@stof
Copy link
Member
stof commented Sep 12, 2013

I think this should be documented. When using the HttpCache, you need to call the method in your front controller instead of relying on the parameter

@kbond
Copy link
Member Author
kbond commented Sep 12, 2013

Should I make a note anywhere else?

fabpot added a commit that referenced this issue Sep 12, 2013
This PR was merged into the master branch.

Discussion
----------

[FrameworkBundle] Added comment about http_method_override and HttpCache

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #8481
| License       | MIT
| Doc PR        | n/a

Commits
-------

52d2bdd Added comment about http_method_override and HttpCache
fabpot added a commit to symfony/symfony-standard that referenced this issue Sep 27, 2013
…bond)

This PR was merged into the master branch.

Discussion
----------

Added comment about http_method_override and HttpCache

related: symfony/symfony#8481

Commits
-------

b6ee002 Added comment about http_method_override and HttpCache
@phiamo
Copy link
phiamo commented Feb 11, 2014

@kbond @fabpot I was searching for this quite extensive and didnt find this issue until i got a friendly notice in the sonata-users group, i think this should somehow be mentioned on the httpcache docu page especially if this is still an issue.

@cordoval
Copy link
Contributor

correct this was not included here https://github.com/symfony/symfony-docs/pull/2355/files

so i have opened this symfony/symfony-docs#3569

@kbond
Copy link
Member Author
kbond commented Feb 11, 2014

I added a note to the config: #9013 and a note in the front controller of symfony-standard: symfony/symfony-standard#592 but yeah, a note should be added to the docs too.

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

7 participants
0