Skip to content

Commit

Permalink
fix: handle empty array
Browse files Browse the repository at this point in the history
Signed-off-by: Git'Fellow <[email protected]>
  • Loading branch information
solracsf authored Nov 17, 2024
1 parent 2db7387 commit b391bb6
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lib/private/Memcache/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,13 @@ public function clear($prefix = '') {
$deletedCount = 0;

// Use SCAN to iterate over keys
$cursor = 0;
$cursor = null;
do {
$arr_keys = $cache->scan($cursor, $prefix);
if ($arr_keys === false) {
return false;
}

[$cursor, $keys] = $arr_keys;
if (!empty($keys)) {
$keys = $cache->scan($cursor, $prefix);

Check failure on line 97 in lib/private/Memcache/Redis.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

NullArgument

lib/private/Memcache/Redis.php:97:25: NullArgument: Argument 1 of Redis::scan cannot be null, null value provided to parameter with type int (see https://psalm.dev/057)
if ($keys !== false) {
$deletedCount += $cache->unlink($keys);

Check failure on line 99 in lib/private/Memcache/Redis.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

InvalidArgument

lib/private/Memcache/Redis.php:99:37: InvalidArgument: Argument 1 of RedisCluster::unlink expects string, but array<array-key, mixed> provided (see https://psalm.dev/004)
}
} while ($cursor !== 0);
} while ($cursor > 0);

return $deletedCount > 0;
}
Expand Down

0 comments on commit b391bb6

Please sign in to comment.