fix(CleanupRedis): guard against scan() returning false and use lowercase option keys

- Change Redis scan() option keys from uppercase (MATCH, COUNT) to lowercase (match, count) to comply with PhpRedis requirements
- Add guard to handle scan() returning false and display error message
- Add comprehensive test coverage for scan() error handling scenarios
This commit is contained in:
Andras Bacsai
2025-11-11 21:22:29 +01:00
parent ad69758c56
commit 6202803db2
2 changed files with 134 additions and 1 deletions

View File

@@ -359,7 +359,14 @@ class CleanupRedis extends Command
$cursor = 0;
$keys = [];
do {
$result = $redis->scan($cursor, ['MATCH' => '*', 'COUNT' => 100]);
$result = $redis->scan($cursor, ['match' => '*', 'count' => 100]);
// Guard against scan() returning false
if ($result === false) {
$this->error('Redis scan failed, stopping key retrieval');
break;
}
$cursor = $result[0];
$keys = array_merge($keys, $result[1]);
} while ($cursor !== 0);