Skip to content

Navigation Menu

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] Regression in using the session in kernel.terminate #40778

Copy link
Copy link
Closed
@wouterj

Description

@wouterj
Issue body actions

Symfony version(s) affected: 5.x

Description

I was testing one of our main apps in 5.x and discovered a regression with the new session logic when using the token storage, causing "There is currently no session available." (related change: #38616)

We use a listener on kernel.terminate to log some information (including the current username). However, RequestStack::getSession() only works when there is a main request (which is not the case in the kernel.terminate event). Before 5.3, the session service was usable outside a main request.
The fix on our side was quite easy: use the security.untracked_token_storage service. Yet, I do believe there should be no hard breaks

How to reproduce

  1. Create a listener on kernel.terminate
  2. Try to use the session

Possible Solution

Maybe store the main $request->getSession() (in RequestStack::push()) in a variable and use it when there is no main request anymore? (and immediately deprecate this behavior) This way, there is no hard break between the version upgrade and there is a way to direct the user into the right debugging path.

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.