@@ -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