summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
authorMichael Long <mchobbylong@gmail.com>2019-08-12 05:58:40 +0200
committerMichael Long <mchobbylong@gmail.com>2019-08-12 05:58:40 +0200
commit7d741c2ba0cc694b57469c692bb0b197e0127e95 (patch)
tree30ad7200f161159d2e204a0271adef185873f8ef /system/libraries
parent66b1bf6145537b02e7386e783ffd60112f33baf6 (diff)
Adapt to new version of php-redis
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Session/drivers/Session_redis_driver.php45
1 files changed, 39 insertions, 6 deletions
diff --git a/system/libraries/Session/drivers/Session_redis_driver.php b/system/libraries/Session/drivers/Session_redis_driver.php
index 9ff6a0e1f..4976e9473 100644
--- a/system/libraries/Session/drivers/Session_redis_driver.php
+++ b/system/libraries/Session/drivers/Session_redis_driver.php
@@ -240,7 +240,7 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
$this->_session_id = $session_id;
}
- $this->_redis->setTimeout($this->_lock_key, 300);
+ $this->_expire($this->_lock_key, 300);
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']))
@@ -253,7 +253,7 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
return $this->_fail();
}
- return ($this->_redis->setTimeout($this->_key_prefix.$session_id, $this->_config['expiration']))
+ return ($this->_expire($this->_key_prefix.$session_id, $this->_config['expiration']))
? $this->_success
: $this->_fail();
}
@@ -272,7 +272,8 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
if (isset($this->_redis))
{
try {
- if ($this->_redis->ping() === '+PONG')
+ $ping = $this->_redis->ping();
+ if ($ping === '+PONG' || $ping === TRUE)
{
$this->_release_lock();
if ($this->_redis->close() === FALSE)
@@ -307,9 +308,9 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
{
if (isset($this->_redis, $this->_lock_key))
{
- if (($result = $this->_redis->delete($this->_key_prefix.$session_id)) !== 1)
+ if (($result = $this->_delete($this->_key_prefix.$session_id)) !== 1)
{
- log_message('debug', 'Session: Redis::delete() expected to return 1, got '.var_export($result, TRUE).' instead.');
+ log_message('debug', 'Session: Redis::del() expected to return 1, got '.var_export($result, TRUE).' instead.');
}
$this->_cookie_destroy();
@@ -368,7 +369,7 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
// correct session ID.
if ($this->_lock_key === $this->_key_prefix.$session_id.':lock')
{
- return $this->_redis->setTimeout($this->_lock_key, 300);
+ return $this->_expire($this->_lock_key, 300);
}
// 30 attempts to obtain a lock, in case another request already has it
@@ -439,4 +440,36 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
return TRUE;
}
+ // ------------------------------------------------------------------------
+
+ /**
+ * Expire
+ *
+ * Sets expiration for a key
+ *
+ * @return bool
+ */
+ protected function _expire($key, $timeout)
+ {
+ if (method_exists($this->_redis, 'expire'))
+ return $this->_redis->expire($key, $timeout);
+ return $this->_redis->setTimeout($key, $timeout);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Delete
+ *
+ * Deletes a key
+ *
+ * @return bool
+ */
+ protected function _delete($key)
+ {
+ if (method_exists($this->_redis, 'del'))
+ return $this->_redis->del($key);
+ return $this->_redis->delete($key);
+ }
+
}