Closed
Description
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:
- either allow a way to restore
Request::$formats
in aResetInterface
tonull
(although this solution makes the static not so useful) - set a local variable (
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