-
Notifications
You must be signed in to change notification settings - Fork 21
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
FIX Return an emtpy string instead of false from HybridSession::read() #83
FIX Return an emtpy string instead of false from HybridSession::read() #83
Conversation
0f2717e
to
539cc54
Compare
README.md
Outdated
@@ -17,12 +17,12 @@ multi-server issues like asset storage and databases). | |||
|
|||
## Installation | |||
|
|||
* Install with composer using `composer require silverstripe/hybridsessions:*` | |||
* Install with composer using `composer require silverstripe/hybridsessions:^5` |
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.
Did you mean ^3 (and the ^5 was because of CMS 5)?
* Install with composer using `composer require silverstripe/hybridsessions:^5` | |
* Install with composer using `composer require silverstripe/hybridsessions:^3` |
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.
Have removed the version as per Guys review below
src/HybridSession.php
Outdated
|
||
return false; | ||
// Return a blank string if no record was found in any store | ||
// The "session" still exists in memory until a new record will be created |
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 "session" still exists in memory until a new record will be created | |
// The "session" still exists in memory until a new record is created |
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.
Updated
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.
Also add a comment above return true;
in open() something along the lines of
Our interpretation of "or creates a new one" in https://www.php.net/manual/en/sessionhandlerinterface.open.php allows for the session to have been created in memory, to be stored by the appropriate handler on
session_write_close()
. If the session fails to be written, we returnfalse
inwrite()
, so we will be alerted to there being some error.
Alternatively, we could return false
from open()
if all of the stores return false
which would indicate that none of the stores are going to be able to write the session when the session ends. This would also require changing open()
of the child handlers to return false
if they won't be able to store stuff (db not available, and the checks that are in write()
for the cookie handler)
Either one of these - a comment explaining our thinking and interpretation of the docs (or returning false if all handlers return false from open) will be fine.
README.md
Outdated
@@ -17,12 +17,12 @@ multi-server issues like asset storage and databases). | |||
|
|||
## Installation | |||
|
|||
* Install with composer using `composer require silverstripe/hybridsessions:*` | |||
* Install with composer using `composer require silverstripe/hybridsessions:^5` |
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.
* Install with composer using `composer require silverstripe/hybridsessions:^5` | |
* Install with composer using `composer require silverstripe/hybridsessions` |
Composer knows what version is right. Specifying here just gives us another thing we have to change next major.
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.
Updated
src/HybridSession.php
Outdated
// Return a blank string if no record was found in any store | ||
// The "session" still exists in memory until a new record will be created | ||
// in the first writable store in write() | ||
// This prevents `PHP Warning: session_start(): Failed to read session data: user` | ||
// when session_start() is called within SilverStripe\Control\Session::start() | ||
return ''; |
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.
// Return a blank string if no record was found in any store | |
// The "session" still exists in memory until a new record will be created | |
// in the first writable store in write() | |
// This prevents `PHP Warning: session_start(): Failed to read session data: user` | |
// when session_start() is called within SilverStripe\Control\Session::start() | |
return ''; | |
// Return a blank string if no record was found in any store | |
// The "session" still exists in memory until a new record will be created | |
// in the first writable store in write() | |
// Our interpretation then of "If the record was not found" in https://www.php.net/manual/en/sessionhandlerinterface.read.php | |
// is that we have "found" the NEW session in memory. | |
// This prevents `PHP Warning: session_start(): Failed to read session data: user` | |
// when session_start() is called within SilverStripe\Control\Session::start() | |
return ''; |
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.
Updated
@GuySartorelli I've added the comment to open() rather than changing return types |
539cc54
to
7aede67
Compare
Issue #82
Reverts change from https://github.com/silverstripe/silverstripe-hybridsessions/pull/79/files#diff-ca4ddcb65cd9d12ea026a139173f0ece0c7ac066adb9b027c2f4f802bd42f936R78