Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpFoundation] [Session] lazy session start for #6036 #10156

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

Closed
wants to merge 1 commit into from
Closed

[HttpFoundation] [Session] lazy session start for #6036 #10156

wants to merge 1 commit into from

Conversation

ewgRa
Copy link
Contributor

@ewgRa ewgRa commented Jan 29, 2014

Q A
Bug fix? no
New feature? no
BC breaks? yes
Deprecations? no
Tests pass? yes
Fixed tickets #6036
License MIT
Doc PR

This patch solve problem when session starts after call read method like get, has, count without checking that session isStarted.

@stof
Copy link
Member

stof commented Jan 29, 2014

This is breaking functional tests of the SecurityBundle (which rely on the session), so something is wrong in your patch

@ewgRa
Copy link
Contributor Author

ewgRa commented Jan 29, 2014

Will check it later. Seems that there is nobody try to start session at login

@ewgRa
Copy link
Contributor Author

ewgRa commented Feb 22, 2014

Done.

As I said before there is BC, Security tests don't start session at login action, but has option "require_previous_session", this why they don't pass. I make changes in that tests to fix this.

Also I create another PR #10310 that haven't BC problem, but use less right way. On my mind #10310 is better PR, people who care about start session on read operation can use its own storage, that implement LazySessionStorageInterface, and don't need to wait major version. And later on major version this interface can be merged with SessionStorageInterface with BC.

@ewgRa
Copy link
Contributor Author

ewgRa commented Feb 23, 2014

I think to close this PR, because of this line in storage:

return isset($_COOKIE[session_name()]);

Actually hasPreviousSession in Storage must have Request to work like in Request::hasPreviousSession, but this is very big changes and I'm not sure that this will be right changes and now I haven't idea, how to solve this.

*
* @return boolean True if previous session exiting, false otherwise.
*/
public function hasPreviousSession();
Copy link
Contributor

Choose a reason for hiding this comment

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

The SessionStorageInterface is marked as API so it can't be changed.

Its best to introduce a new additional Interface to solve this - LazySessionStorageInterface?
And then check if the storage implements this interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In #10310 I make it in this way.

@sstok
Copy link
Contributor

sstok commented Feb 23, 2014

Isn't this a compatibility break, as the session no longer starts automatically?

Maybe a add a new LazySession class which implements this 'new' logic without breaking the current situation. In the new class you then can enforce that that the storage implements lazy loading (LazySessionStorageInterface).

@ewgRa
Copy link
Contributor Author

ewgRa commented Feb 23, 2014

Isn't this a compatibility break, as the session no longer starts automatically?
Kind of. Now it starts automatically even on read operations, where is no session at all.
For example if I call Session::get - session will be started and it is easy (and not obvious) that you first need to check isStarted().

I will think about LazySessionInterface or maybe just check only isStarted inside Session read methods (without additionally check hasPreviousSession).

@ewgRa ewgRa closed this Mar 12, 2014
@ewgRa ewgRa deleted the issue_6036_start_session_at_read branch March 12, 2014 20:48
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.

3 participants