Skip to content
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

Updated redis session handler to support redis 5.0.x #2125

Merged
merged 1 commit into from
Aug 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions system/Session/Handlers/RedisHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function write($sessionID, $sessionData): bool

if (isset($this->lockKey))
{
$this->redis->setTimeout($this->lockKey, 300);
$this->redis->expire($this->lockKey, 300);

if ($this->fingerprint !== ($fingerprint = md5($sessionData)) || $this->keyExists === false)
{
Expand All @@ -243,7 +243,7 @@ public function write($sessionID, $sessionData): bool
return false;
}

return $this->redis->setTimeout($this->keyPrefix . $sessionID, $this->sessionExpiration);
return $this->redis->expire($this->keyPrefix . $sessionID, $this->sessionExpiration);
}

return false;
Expand All @@ -264,9 +264,10 @@ public function close(): bool
{
try
{
if ($this->redis->ping() === '+PONG')
$ping_reply = $this->redis->ping();
if (($ping_reply === true) || ($ping_reply === '+PONG'))
{
isset($this->lockKey) && $this->redis->delete($this->lockKey);
isset($this->lockKey) && $this->redis->del($this->lockKey);

if (! $this->redis->close())
{
Expand Down Expand Up @@ -302,9 +303,9 @@ public function destroy($sessionID): bool
{
if (isset($this->redis, $this->lockKey))
{
if (($result = $this->redis->delete($this->keyPrefix . $sessionID)) !== 1)
if (($result = $this->redis->del($this->keyPrefix . $sessionID)) !== 1)
{
$this->logger->debug('Session: Redis::delete() expected to return 1, got ' . var_export($result, true) . ' instead.');
$this->logger->debug('Session: Redis::del() expected to return 1, got ' . var_export($result, true) . ' instead.');
}

return $this->destroyCookie();
Expand Down Expand Up @@ -347,7 +348,7 @@ protected function lockSession(string $sessionID): bool
// correct session ID.
if ($this->lockKey === $this->keyPrefix . $sessionID . ':lock')
{
return $this->redis->setTimeout($this->lockKey, 300);
return $this->redis->expire($this->lockKey, 300);
}

// 30 attempts to obtain a lock, in case another request already has it
Expand Down Expand Up @@ -400,7 +401,7 @@ protected function releaseLock(): bool
{
if (isset($this->redis, $this->lockKey) && $this->lock)
{
if (! $this->redis->delete($this->lockKey))
if (! $this->redis->del($this->lockKey))
{
$this->logger->error('Session: Error while trying to free lock for ' . $this->lockKey);
return false;
Expand Down