8000 bug #59488 [Lock] Make sure RedisStore will also support Valkey (PatN… · symfony/symfony@a8a9e0b · GitHub
[go: up one dir, main page]

Skip to content

Commit a8a9e0b

Browse files
committed
bug #59488 [Lock] Make sure RedisStore will also support Valkey (PatNowak)
This PR was submitted for the 7.3 branch but it was squashed and merged into the 7.2 branch instead. Discussion ---------- [Lock] Make sure RedisStore will also support Valkey | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #59387 | License | MIT As the change happened on Valkey (https://github.com/valkey-io/valkey/pull/617/files#diff-1abc5651133d108c0c420d9411925373c711133e7748d9e4f4c97d5fb543fdd9L1819-R1819), ~it's hard to consider this a bug when `RedisStore` was meant only to support Redis ;)~ Commits ------- 15d6b5e [Lock] Make sure RedisStore will also support Valkey
2 parents 30e559f + 15d6b5e commit a8a9e0b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Symfony/Component/Lock/Store/RedisStore.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class RedisStore implements SharedLockStoreInterface
2929
{
3030
use ExpiringStoreTrait;
3131

32-
private const NO_SCRIPT_ERROR_MESSAGE = 'NOSCRIPT No matching script. Please use EVAL.';
32+
private const NO_SCRIPT_ERROR_MESSAGE_PREFIX = 'NOSCRIPT No matching script.';
3333

3434
private bool $supportTime;
3535

@@ -234,7 +234,7 @@ private function evaluate(string $script, string $resource, array $args): mixed
234234
$this->redis->clearLastError();
235235

236236
$result = $this->redis->evalSha($scriptSha, array_merge([$resource], $args), 1);
237-
if (self::NO_SCRIPT_ERROR_MESSAGE === $err = $this->redis->getLastError()) {
237+
if (null !== ($err = $this->redis->getLastError()) && str_starts_with($err, self::NO_SCRIPT_ERROR_MESSAGE_PREFIX)) {
238238
$this->redis->clearLastError();
239239

240240
if ($this->redis instanceof \RedisCluster) {
@@ -263,7 +263,7 @@ private function evaluate(string $script, string $resource, array $args): mixed
263263
$client = $this->redis->_instance($this->redis->_target($resource));
264264
$client->clearLastError();
265265
$result = $client->evalSha($scriptSha, array_merge([$resource], $args), 1);
266-
if (self::NO_SCRIPT_ERROR_MESSAGE === $err = $client->getLastError()) {
266+
if (null !== ($err = $this->redis->getLastError()) && str_starts_with($err, self::NO_SCRIPT_ERROR_MESSAGE_PREFIX)) {
267267
$client->clearLastError();
268268

269269
$client->script('LOAD', $script);
@@ -285,7 +285,7 @@ private function evaluate(string $script, string $resource, array $args): mixed
285285
\assert($this->redis instanceof \Predis\ClientInterface);
286286

287287
$result = $this->redis->evalSha($scriptSha, 1, $resource, ...$args);
288-
if ($result instanceof Error && self::NO_SCRIPT_ERROR_MESSAGE === $result->getMessage()) {
288+
if ($result instanceof Error && str_starts_with($result->getMessage(), self::NO_SCRIPT_ERROR_MESSAGE_PREFIX)) {
289289
$result = $this->redis->script('LOAD', $script);
290290
if ($result instanceof Error) {
291291
throw new LockStorageException($result->getMessage());

0 commit comments

Comments
 (0)
0