Skip to content

[HttpKernel] Fix session initialized several times #38910

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

Merged
merged 1 commit into from
Nov 2, 2020

Conversation

jderusse
Copy link
Member

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

The session injected in the request is a factory. When the request is cloned (ie sub-request) while the session is not yet used in the master request (the session is still a factory), both Master and Sub request will have a factory.
If both requests attempt to read the session afterward, they both triggers the factory, and both initialize the session.

It's not a dead end for the SessionListener because the session come from the container and is shared, but:

  • the session is initialized ($storage->setOptions(['cookie_secure' => true])) twice
  • if we replace the sesssion from container to a factory, it could be an issue

@carsonbot carsonbot added this to the 4.4 milestone Oct 30, 2020
@jderusse jderusse changed the title [HttpKernel] Fix session called initized several time [HttpKernel] Fix session called initialized several time Oct 30, 2020
@jderusse jderusse changed the title [HttpKernel] Fix session called initialized several time [HttpKernel] Fix session called initialized several times Oct 30, 2020
@Nyholm
Copy link
Member

Nyholm commented Oct 30, 2020

Could I ask you for a test too?

@jderusse jderusse changed the title [HttpKernel] Fix session called initialized several times [HttpKernel] Fix session initialized several times Oct 30, 2020
@nicolas-grekas
Copy link
Member

Thank you @jderusse.

@nicolas-grekas nicolas-grekas merged commit 5831ab2 into symfony:4.4 Nov 2, 2020
@@ -20,11 +20,13 @@
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
Copy link
Member

@nicolas-grekas nicolas-grekas Nov 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is deprecated, I'm fixing it in the source directly, see 76c1939

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants