summaryrefslogtreecommitdiffstats
path: root/system/libraries/Session/drivers
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2016-02-05 13:36:50 +0100
committerAndrey Andreev <narf@devilix.net>2016-02-05 13:38:12 +0100
commit173cf413d38be042b40c2e519041ecaafb6a0919 (patch)
tree2d7b64297da65199e3a1752d30d2dda51bc91809 /system/libraries/Session/drivers
parent95bd763784f215a5cb4c38a4bc1caf5ac3c8f72d (diff)
Merge pull request #4424 from jonty-comp/develop
[ci skip] Fix PHP session_write_close() warning when writing a new session to Redis
Diffstat (limited to 'system/libraries/Session/drivers')
-rw-r--r--system/libraries/Session/drivers/Session_redis_driver.php19
1 files changed, 16 insertions, 3 deletions
diff --git a/system/libraries/Session/drivers/Session_redis_driver.php b/system/libraries/Session/drivers/Session_redis_driver.php
index 46b8fa1c2..ad95309da 100644
--- a/system/libraries/Session/drivers/Session_redis_driver.php
+++ b/system/libraries/Session/drivers/Session_redis_driver.php
@@ -69,6 +69,13 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
*/
protected $_lock_key;
+ /**
+ * Key exists flag
+ *
+ * @var bool
+ */
+ protected $_key_exists = FALSE;
+
// ------------------------------------------------------------------------
/**
@@ -166,7 +173,12 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
// Needed by write() to detect session_regenerate_id() calls
$this->_session_id = $session_id;
- $session_data = (string) $this->_redis->get($this->_key_prefix.$session_id);
+ $session_data = $this->_redis->get($this->_key_prefix.$session_id);
+
+ is_string($session_data)
+ ? $this->_key_exists = TRUE
+ : $session_data = '';
+
$this->_fingerprint = md5($session_data);
return $session_data;
}
@@ -199,18 +211,19 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
return $this->_failure;
}
- $this->_fingerprint = md5('');
+ $this->_key_exists = FALSE;
$this->_session_id = $session_id;
}
if (isset($this->_lock_key))
{
$this->_redis->setTimeout($this->_lock_key, 300);
- if ($this->_fingerprint !== ($fingerprint = md5($session_data)))
+ if ($this->_fingerprint !== ($fingerprint = md5($session_data)) OR $this->_key_exists === FALSE)
{
if ($this->_redis->set($this->_key_prefix.$session_id, $session_data, $this->_config['expiration']))
{
$this->_fingerprint = $fingerprint;
+ $this->_key_exists = TRUE;
return $this->_success;
}