diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php index 5569a5ab19ffe..c5f34deeca13f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php @@ -70,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $clearers = []; $poolNames = $input->getArgument('pools'); - if ($input->getOption('all')) { + if ($clearAll = $input->getOption('all')) { if (!$this->poolNames) { throw new InvalidArgumentException('Could not clear all cache pools, try specifying a specific pool or cache clearer.'); } @@ -84,7 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int foreach ($poolNames as $id) { if ($this->poolClearer->hasPool($id)) { $pools[$id] = $id; - } else { + } elseif (!$clearAll || $kernel->getContainer()->has($id)) { $pool = $kernel->getContainer()->get($id); if ($pool instanceof CacheItemPoolInterface) {