Skip to content

RequestContext parameter "_locale" should be resetted between requests #61762

@andrew-demb

Description

@andrew-demb

Description

LocaleListener sets _locale parameter to RequestContext on kernel.request (16 priority), but there's no code that resets this value for long-running applications

$this->router?->getContext()->setParameter('_locale', $request->getLocale());


In our case, we found a side-effect for our long-running application in our own kernel.request listener (35 priority), that checks RequestContext - for the first request, there was no _locale parameter, but for the second - there is _locale parameter with value from previous request

The first idea that came to me was to implement kernel.reset tag (\Symfony\Contracts\Service\ResetInterface) for the \Symfony\Component\HttpKernel\EventListener\LocaleListener, which would reset _locale parameter just before processing the next request to avoid side effects for long-running apps

Example

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions