-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] static Request::$formats can't be reset which causes issues in worker mode #59036
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
Comments
The idea of I wonder if the better solution is to just a provide a wrapper in Or the same approach but instead of leaving it to applications to take care of resetting this state, Symfony's kernel should reinitialize formats automatically on |
I'm wondering why ApiPlatform overrides the mime type associated with the |
In a sense, it is, and it's a bug in API Platform for which I've submitted a patch. But I agree with @soyuka and @dunglas that given Symfony provides a public interface to change these mappings in |
This is the point of the |
We can solve this either in HttpKernel or in the runtime component. Which one would make most sense? |
In |
@nicolas-grekas it's better to do it in HttpKernel, otherwise we'll have to patch all runtimes. |
…using the service resetter (nicolas-grekas) This PR was merged into the 6.4 branch. Discussion ---------- [FrameworkBundle][HttpFoundation] Reset Request's formats using the service resetter | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | #59036 | License | MIT Commits ------- 56f3df4 [HttpFoundation][FrameworkBundle] Reset Request's formats using the service resetter
Symfony version(s) affected
6.4, 7.1
Description
In API Platform, we need to add formats per-request. Indeed, each HTTP operation can be configured with specific mime-types.
To do so, we use
Request::setFormat
:symfony/src/Symfony/Component/HttpFoundation/Request.php
Lines 1256 to 1262 in 4ed9d03
We recently stumbled on an issue in worker mode. Indeed as
$formats
is static, its values are sometimes the same as a previous request and we need to merge new formats (api-platform/core#6833) to bypass this issue.Possible Solution
With @dunglas we were thinking of a few solutions:
Request::$formats
in aResetInterface
tonull
(although this solution makes the static not so useful)Request::$currentFormat
) that would fallback on the static value if not defined. This would allow to set formats per-request.Note: to reproduce we can use api-platform/core#6831 or the test at api-platform/core#6833
The text was updated successfully, but these errors were encountered: