Skip to content
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

[HttpFoundation] Add Session::isEmpty(), fix MockFileSessionStorage to behave like the native one #25220

Merged
merged 1 commit into from Nov 30, 2017

Conversation

@nicolas-grekas
Copy link
Member

commented Nov 30, 2017

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 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.

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Nov 30, 2017

@nicolas-grekas nicolas-grekas force-pushed the nicolas-grekas:test-session branch from c54978f to f635ca2 Nov 30, 2017

@@ -29,7 +29,7 @@
protected $options = array(
'check_path' => '/login_check',
'use_forward' => false,
'require_previous_session' => true,
'require_previous_session' => false,

This comment has been minimized.

Copy link
@nicolas-grekas

nicolas-grekas Nov 30, 2017

Author Member

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.

@stof
stof approved these changes Nov 30, 2017
Copy link
Member

left a comment

Looks good to me.

Too bad that this requires a new public method in Session just for the test layer though.

@nicolas-grekas nicolas-grekas force-pushed the nicolas-grekas:test-session branch from f635ca2 to bc3593a Nov 30, 2017

@nicolas-grekas

This comment has been minimized.

Copy link
Member Author

commented Nov 30, 2017

Too bad that this requires a new public method in Session just for the test layer though.

the method is now @internal

@xabbuh
xabbuh approved these changes Nov 30, 2017

@nicolas-grekas nicolas-grekas force-pushed the nicolas-grekas:test-session branch from bc3593a to 56846ac Nov 30, 2017

@nicolas-grekas nicolas-grekas merged commit 56846ac into symfony:3.4 Nov 30, 2017

2 of 3 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
fabbot.io Your code looks good.
Details
nicolas-grekas added a commit that referenced this pull request Nov 30, 2017
bug #25220 [HttpFoundation] Add Session::isEmpty(), fix MockFileSessi…
…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

@nicolas-grekas nicolas-grekas deleted the nicolas-grekas:test-session branch Nov 30, 2017

This was referenced Nov 30, 2017
jpuck added a commit to razorbacks/laravel-shibboleth that referenced this pull request Nov 30, 2017
jpuck added a commit to razorbacks/laravel-shibboleth that referenced this pull request Nov 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.