Skip to content

Commit 9363f3b

Browse files
Wickexnicolas-grekas
authored andcommitted
[Cache] Fixed incorrect usage of UNLINK with PHPRedis with Redis < 4.0
1 parent 2b36487 commit 9363f3b

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,15 +408,15 @@ protected function doDelete(array $ids)
408408

409409
if ($unlink) {
410410
try {
411-
$this->redis->unlink($ids);
412-
413-
return true;
411+
$unlink = false !== $this->redis->unlink($ids);
414412
} catch (\Throwable $e) {
415413
$unlink = false;
416414
}
417415
}
418416

419-
$this->redis->del($ids);
417+
if (!$unlink) {
418+
$this->redis->del($ids);
419+
}
420420
}
421421

422422
return true;

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ protected function doDestroy(string $sessionId): bool
9393

9494
if ($unlink) {
9595
try {
96-
$this->redis->unlink($this->prefix.$sessionId);
97-
98-
return true;
96+
$unlink = false !== $this->redis->unlink($this->prefix.$sessionId);
9997
} catch (\Throwable $e) {
10098
$unlink = false;
10199
}
102100
}
103101

104-
$this->redis->del($this->prefix.$sessionId);
102+
if (!$unlink) {
103+
$this->redis->del($this->prefix.$sessionId);
104+
}
105105

106106
return true;
107107
}

src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -485,17 +485,15 @@ public function cleanup(): void
485485

486486
if ($unlink) {
487487
try {
488-
$this->connection->unlink($this->stream);
489-
$this->connection->unlink($this->queue);
490-
491-
return;
488+
$unlink = false !== $this->connection->unlink($this->stream, $this->queue);
492489
} catch (\Throwable $e) {
493490
$unlink = false;
494491
}
495492
}
496493

497-
$this->connection->del($this->stream);
498-
$this->connection->del($this->queue);
494+
if (!$unlink) {
495+
$this->connection->del($this->stream, $this->queue);
496+
}
499497
}
500498
}
501499
class_alias(Connection::class, \Symfony\Component\Messenger\Transport\RedisExt\Connection::class);

0 commit comments

Comments
 (0)