Skip to content

Commit 5dcc112

Browse files
[FrameworkBundle] Add soft conflict rule of "cache:clear" + HttpKernel 3.4
1 parent 25bc5e5 commit 5dcc112

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Command/CacheClearCommand.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Console\Input\InputOption;
1616
use Symfony\Component\Console\Output\OutputInterface;
1717
use Symfony\Component\Console\Style\SymfonyStyle;
18+
use Symfony\Component\HttpKernel\Kernel;
1819
use Symfony\Component\HttpKernel\KernelInterface;
1920
use Symfony\Component\Finder\Finder;
2021

@@ -56,6 +57,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
5657
{
5758
$io = new SymfonyStyle($input, $output);
5859

60+
if (Kernel::VERSION_ID >= 30400) {
61+
throw new \LogicException('The "cache:clear" command in Symfony 3.3 is incompatible with HttpKernel 3.4, please upgrade "symfony/framework-bundle" or downgrade "symfony/http-kernel".');
62+
}
63+
5964
$realCacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
6065
// the old cache dir name must not be longer than the real one to avoid exceeding
6166
// the maximum length of a directory or file path within it (esp. Windows MAX_PATH)

Tests/Command/CacheClearCommand/CacheClearCommandTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Symfony\Component\Console\Output\NullOutput;
2121
use Symfony\Component\Filesystem\Filesystem;
2222
use Symfony\Component\Finder\Finder;
23+
use Symfony\Component\HttpKernel\Kernel;
2324

2425
class CacheClearCommandTest extends TestCase
2526
{
@@ -49,6 +50,17 @@ public function testCacheIsFreshAfterCacheClearedWithWarmup()
4950
$application = new Application($this->kernel);
5051
$application->setCatchExceptions(false);
5152

53+
if (Kernel::VERSION_ID >= 30400) {
54+
$expectedMsg = 'The "cache:clear" command in Symfony 3.3 is incompatible with HttpKernel 3.4, please upgrade "symfony/framework-bundle" or downgrade "symfony/http-kernel".';
55+
56+
if (method_exists($this, 'expectException')) {
57+
$this->expectException(\LogicException::class);
58+
$this->expectExceptionMessage($expectedMsg);
59+
} else {
60+
$this->setExpectedException(\LogicException::class, $expectedMsg);
61+
}
62+
}
63+
5264
$application->doRun($input, new NullOutput());
5365

5466
// Ensure that all *.meta files are fresh

0 commit comments

Comments
 (0)