Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ CHANGELOG
* Add support for relative URLs in BrowserKit's redirect assertion
* Change BrowserKitAssertionsTrait::getClient() to be protected
* Deprecate the `framework.asset_mapper.provider` config option
* Add `--exclude` option to the `cache:pool:clear` command

6.3
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ protected function configure(): void
new InputArgument('pools', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'A list of cache pools or cache pool clearers'),
])
->addOption('all', null, InputOption::VALUE_NONE, 'Clear all cache pools')
->addOption('exclude', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'A list of cache pools or cache pool clearers to exclude')
->setHelp(<<<'EOF'
The <info>%command.name%</info> command clears the given cache pools or cache pool clearers.

Expand All @@ -70,17 +71,23 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$clearers = [];

$poolNames = $input->getArgument('pools');
$excludedPoolNames = $input->getOption('exclude');
if ($input->getOption('all')) {
if (!$this->poolNames) {
throw new InvalidArgumentException('Could not clear all cache pools, try specifying a specific pool or cache clearer.');
}

$io->comment('Clearing all cache pools...');
if (!$excludedPoolNames) {
$io->comment('Clearing all cache pools...');
}

$poolNames = $this->poolNames;
} elseif (!$poolNames) {
throw new InvalidArgumentException('Either specify at least one pool name, or provide the --all option to clear all pools.');
}

$poolNames = array_diff($poolNames, $excludedPoolNames);

foreach ($poolNames as $id) {
if ($this->poolClearer->hasPool($id)) {
$pools[$id] = $id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ public function testClearFailed()
$this->assertStringContainsString('[WARNING] Cache pool "cache.public_pool" could not be cleared.', $tester->getDisplay());
}

public function testExcludedPool()
{
$tester = $this->createCommandTester(['cache.app_clearer']);
$tester->execute(['--all' => true, '--exclude' => ['cache.app_clearer']], ['decorated' => false]);

$tester->assertCommandIsSuccessful('cache:pool:clear exits with 0 in case of success');
$this->assertStringNotContainsString('Clearing all cache pools...', $tester->getDisplay());
$this->assertStringNotContainsString('Calling cache clearer: cache.app_clearer', $tester->getDisplay());
$this->assertStringContainsString('[OK] Cache was successfully cleared.', $tester->getDisplay());
}

private function createCommandTester(array $poolNames = null)
{
$application = new Application(static::$kernel);
Expand Down