From 9363f3b9730b8e3fc685ed71dff198916c213ecc Mon Sep 17 00:00:00 2001 From: Wickex Date: Thu, 3 Dec 2020 14:31:29 +0100 Subject: [PATCH] [Cache] Fixed incorrect usage of UNLINK with PHPRedis with Redis < 4.0 --- src/Symfony/Component/Cache/Traits/RedisTrait.php | 8 ++++---- .../Session/Storage/Handler/RedisSessionHandler.php | 8 ++++---- .../Messenger/Bridge/Redis/Transport/Connection.php | 10 ++++------ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Symfony/Component/Cache/Traits/RedisTrait.php b/src/Symfony/Component/Cache/Traits/RedisTrait.php index 317879aa49..4932f574e1 100644 --- a/src/Symfony/Component/Cache/Traits/RedisTrait.php +++ b/src/Symfony/Component/Cache/Traits/RedisTrait.php @@ -408,15 +408,15 @@ trait RedisTrait if ($unlink) { try { - $this->redis->unlink($ids); - - return true; + $unlink = false !== $this->redis->unlink($ids); } catch (\Throwable $e) { $unlink = false; } } - $this->redis->del($ids); + if (!$unlink) { + $this->redis->del($ids); + } } return true; diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php index 756a48808e..61714f1743 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php @@ -93,15 +93,15 @@ class RedisSessionHandler extends AbstractSessionHandler if ($unlink) { try { - $this->redis->unlink($this->prefix.$sessionId); - - return true; + $unlink = false !== $this->redis->unlink($this->prefix.$sessionId); } catch (\Throwable $e) { $unlink = false; } } - $this->redis->del($this->prefix.$sessionId); + if (!$unlink) { + $this->redis->del($this->prefix.$sessionId); + } return true; } diff --git a/src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php b/src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php index 7fe21418ca..c447a33802 100644 --- a/src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php +++ b/src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php @@ -485,17 +485,15 @@ class Connection if ($unlink) { try { - $this->connection->unlink($this->stream); - $this->connection->unlink($this->queue); - - return; + $unlink = false !== $this->connection->unlink($this->stream, $this->queue); } catch (\Throwable $e) { $unlink = false; } } - $this->connection->del($this->stream); - $this->connection->del($this->queue); + if (!$unlink) { + $this->connection->del($this->stream, $this->queue); + } } } class_alias(Connection::class, \Symfony\Component\Messenger\Transport\RedisExt\Connection::class);