diff options
author | Andrey Andreev <narf@devilix.net> | 2015-12-12 13:07:39 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2015-12-12 13:07:39 +0100 |
commit | af849696d43f5c3b68962af1ae5096151a6d9f1a (patch) | |
tree | 51a19ef414c953ebe819ded5210e2ac494cb6aa1 /system/libraries/Session/Session_driver.php | |
parent | e705f8e71a80e7740fe6d87f9e01afebc40cd375 (diff) |
[ci skip] Proper error handling for Sessions on PHP 5
This was actually a PHP bug, see https://wiki.php.net/rfc/session.user.return-value
Also related: #4039
Diffstat (limited to 'system/libraries/Session/Session_driver.php')
-rw-r--r-- | system/libraries/Session/Session_driver.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/system/libraries/Session/Session_driver.php b/system/libraries/Session/Session_driver.php index 47376da5b..64b4bb511 100644 --- a/system/libraries/Session/Session_driver.php +++ b/system/libraries/Session/Session_driver.php @@ -74,6 +74,18 @@ abstract class CI_Session_driver implements SessionHandlerInterface { */ protected $_session_id; + /** + * Success and failure return values + * + * Necessary due to a bug in all PHP 5 versions where return values + * from userspace handlers are not handled properly. PHP 7 fixes the + * bug, so we need to return different values depending on the version. + * + * @see https://wiki.php.net/rfc/session.user.return-value + * @var mixed + */ + protected $_success, $_failure; + // ------------------------------------------------------------------------ /** @@ -85,6 +97,17 @@ abstract class CI_Session_driver implements SessionHandlerInterface { public function __construct(&$params) { $this->_config =& $params; + + if (is_php('7')) + { + $this->_success = TRUE; + $this->_failure = FALSE; + } + else + { + $this->_success = 0; + $this->_failure = -1; + } } // ------------------------------------------------------------------------ |