Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[HttpFoundation] static Request::$formats can't be reset which causes issues in worker mode #59036

Copy link
Copy link
Closed
@soyuka

Description

@soyuka
Issue body actions

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:

public function setFormat(?string $format, string|array $mimeTypes): void
{
if (null === static::$formats) {
static::initializeFormats();
}
static::$formats[$format] = \is_array($mimeTypes) ? $mimeTypes : [$mimeTypes];

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 a ResetInterface to null (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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.