-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] Add Session::isEmpty(), fix MockFileSessionStorage to behave like the native one #25220
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
Conversation
c54978f
to
f635ca2
Compare
@@ -29,7 +29,7 @@ | |||
protected $options = array( | |||
'check_path' => '/login_check', | |||
'use_forward' => false, | |||
'require_previous_session' => true, | |||
'require_previous_session' => false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Request::hasPreviousSession()
check that this triggers is a micro-optimization that doesn't make sense, and in fact doesn't work anymore now that we destroy any empty session.
The only case were it can make sense is for remember-me strategy, and this is still enabled there as RememberMeFactory replaces this $options array, and the default is true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Too bad that this requires a new public method in Session just for the test layer though.
f635ca2
to
bc3593a
Compare
the method is now |
…o behave like the native one
bc3593a
to
56846ac
Compare
…onStorage to behave like the native one (nicolas-grekas) This PR was merged into the 3.4 branch. Discussion ---------- [HttpFoundation] Add Session::isEmpty(), fix MockFileSessionStorage to behave like the native one | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - MockFileSessionStorage should not create any file when the session is empty. Like the native session storage, it should ignore the metadataBag to decide if the session is empty. And to prevent AbstractTestSessionListener from registered a wrong cookie, it must have access to this empty state, which is now possible thanks to a new `Session::isEmpty()` method. Implementing is requires access to the internal storage of bags, which is possible via an internal proxy. Commits ------- 56846ac [HttpFoundation] Add Session::isEmpty(), fix MockFileSessionStorage to behave like the native one
symfony/symfony#25220 solution was to stop testing in processIsolation https://stackoverflow.com/a/38615131/4233593
MockFileSessionStorage should not create any file when the session is empty. Like the native session storage, it should ignore the metadataBag to decide if the session is empty.
And to prevent AbstractTestSessionListener from registering a wrong cookie, it must have access to this empty state, which is now possible thanks to a new
Session::isEmpty()
method. Implementing it requires access to the internal storage of bags, which is possible via an internal proxy.