framework
framework copied to clipboard
Flushing Redis Cluster using Predis 2.0.2 is not supported
- Laravel Version: 9..46.0
- PHP Version: 8.1
Description:
When the cache driver is Redis the app isn't started (CACHE_DRIVER=redis) I'm getting "Predis\Command\ServerFlushDatabase" not found when I searched this class on the Predis package I saw that they remove it from the current source code.
Steps To Reproduce:
Update predis/predis to version 2.0.2, update the env to CACHE_DRIVER=redis, and run the app.
Logs:
[2023-01-05 17:29:32] local.CRITICAL: []Class "Predis\Command\ServerFlushDatabase" not found T:0.3708 M:40.50MB
[2023-01-05 17:29:32] local.DEBUG: Exception class (Error) StackTrace:
#0 /var/www/vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php(233): Illuminate\Redis\Connections\PredisClusterConnection->flushdb()
#1 /var/www/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(668): Illuminate\Cache\RedisStore->flush()
#2 /var/www/vendor/laravel/framework/src/Illuminate/Cache/Console/ClearCommand.php(80): Illuminate\Cache\Repository->__call('flush', Array)
#3 /var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Cache\Console\ClearCommand->handle()
#4 /var/www/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#5 /var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#6 /var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#7 /var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php(651): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#8 /var/www/vendor/laravel/framework/src/Illuminate/Console/Command.php(178): Illuminate\Container\Container->call(Array)
#9 /var/www/vendor/symfony/console/Command/Command.php(308): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#10 /var/www/vendor/laravel/framework/src/Illuminate/Console/Command.php(148): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#11 /var/www/vendor/symfony/console/Application.php(1014): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Cache\Console\ClearCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symf
ony\Component\Console\Output\ConsoleOutput))
#13 /var/www/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/vendor/laravel/framework/src/Illuminate/Console/Application.php(102): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\Co
nsoleOutput))
#15 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(155): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\Con
soleOutput))
#16 /var/www/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
Thanks for reporting. @tillkruss what would be the upgrade path here?
It's Predis\Command\ServerFlushDatabase on 1.x and Predis\Command\Redis\FLUSHDB on 2.x
This needs to be adjusted in: https://github.com/laravel/framework/blob/9.x/src/Illuminate/Redis/Connections/PredisClusterConnection.php
The method
Predis\Connection\Cluster\PredisCluster::executeCommandOnNodes()has been removed as it is possible to achieve the same by iterating over the connection or, even better, over the client instance in order to execute the same command against all of the registered connections.
@tillkruss can you give https://github.com/laravel/framework/pull/45544 a review?