[FrameworkBundle] deprecated cache:clear with warmup
This commit is contained in:
parent
7f7b897ee2
commit
7ed3237645
@ -123,6 +123,9 @@ Finder
|
||||
FrameworkBundle
|
||||
---------------
|
||||
|
||||
* The `cache:clear` command should always be called with the `--no-warmup` option.
|
||||
Warmup should be done via the `cache:warmup` command.
|
||||
|
||||
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConsoleCommandPass` has been deprecated. Use `Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass` instead.
|
||||
|
||||
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SerializerPass` class has been
|
||||
|
@ -124,7 +124,7 @@ EventDispatcher
|
||||
Use `EventDispatcher` with closure-proxy injection instead.
|
||||
|
||||
ExpressionLanguage
|
||||
----------
|
||||
------------------
|
||||
|
||||
* The ability to pass a `ParserCacheInterface` instance to the `ExpressionLanguage`
|
||||
class has been removed. You should use the `CacheItemPoolInterface` interface
|
||||
@ -187,6 +187,9 @@ Form
|
||||
FrameworkBundle
|
||||
---------------
|
||||
|
||||
* The `cache:clear` command does not warmup the cache anymore. Warmup should
|
||||
be done via the `cache:warmup` command.
|
||||
|
||||
* Support for absolute template paths has been removed.
|
||||
|
||||
* The following form types registered as services have been removed; use their
|
||||
|
@ -4,6 +4,7 @@ CHANGELOG
|
||||
3.3.0
|
||||
-----
|
||||
|
||||
* Deprecated `cache:clear` with warmup (always call it with `--no-warmup`)
|
||||
* Changed default configuration for
|
||||
assets/forms/validation/translation/serialization/csrf from `canBeEnabled()` to
|
||||
`canBeDisabled()` when Flex is used
|
||||
|
@ -54,7 +54,6 @@ EOF
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$outputIsVerbose = $output->isVerbose();
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
$realCacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
|
||||
@ -78,19 +77,42 @@ EOF
|
||||
if ($input->getOption('no-warmup')) {
|
||||
$filesystem->rename($realCacheDir, $oldCacheDir);
|
||||
} else {
|
||||
@trigger_error('Calling cache:clear without the --no-warmup option is deprecated since version 3.3. Cache warmup should be done with the cache:warmup command instead.', E_USER_DEPRECATED);
|
||||
|
||||
$this->warmupCache($input, $output, $realCacheDir, $oldCacheDir);
|
||||
}
|
||||
|
||||
if ($output->isVerbose()) {
|
||||
$io->comment('Removing old cache directory...');
|
||||
}
|
||||
|
||||
$filesystem->remove($oldCacheDir);
|
||||
|
||||
if ($output->isVerbose()) {
|
||||
$io->comment('Finished');
|
||||
}
|
||||
|
||||
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully cleared.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
|
||||
}
|
||||
|
||||
private function warmupCache(InputInterface $input, OutputInterface $output, $realCacheDir, $oldCacheDir)
|
||||
{
|
||||
$filesystem = $this->getContainer()->get('filesystem');
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
// the warmup cache dir name must have the same length than the real one
|
||||
// to avoid the many problems in serialized resources files
|
||||
$realCacheDir = realpath($realCacheDir);
|
||||
$warmupDir = substr($realCacheDir, 0, -1).('_' === substr($realCacheDir, -1) ? '-' : '_');
|
||||
|
||||
if ($filesystem->exists($warmupDir)) {
|
||||
if ($outputIsVerbose) {
|
||||
if ($output->isVerbose()) {
|
||||
$io->comment('Clearing outdated warmup directory...');
|
||||
}
|
||||
$filesystem->remove($warmupDir);
|
||||
}
|
||||
|
||||
if ($outputIsVerbose) {
|
||||
if ($output->isVerbose()) {
|
||||
$io->comment('Warming up cache...');
|
||||
}
|
||||
$this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));
|
||||
@ -102,23 +124,12 @@ EOF
|
||||
$filesystem->rename($warmupDir, $realCacheDir);
|
||||
}
|
||||
|
||||
if ($outputIsVerbose) {
|
||||
$io->comment('Removing old cache directory...');
|
||||
}
|
||||
|
||||
$filesystem->remove($oldCacheDir);
|
||||
|
||||
if ($outputIsVerbose) {
|
||||
$io->comment('Finished');
|
||||
}
|
||||
|
||||
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully cleared.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $warmupDir
|
||||
* @param string $realCacheDir
|
||||
* @param bool $enableOptionalWarmers
|
||||
*
|
||||
* @internal to be removed in 4.0
|
||||
*/
|
||||
protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = true)
|
||||
{
|
||||
@ -183,6 +194,8 @@ EOF
|
||||
* @param string $warmupDir
|
||||
*
|
||||
* @return KernelInterface
|
||||
*
|
||||
* @internal to be removed in 4.0
|
||||
*/
|
||||
protected function getTempKernel(KernelInterface $parent, $namespace, $parentClass, $warmupDir)
|
||||
{
|
||||
|
@ -43,6 +43,9 @@ class CacheClearCommandTest extends TestCase
|
||||
$this->fs->remove($this->rootDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testCacheIsFreshAfterCacheClearedWithWarmup()
|
||||
{
|
||||
$input = new ArrayInput(array('cache:clear'));
|
||||
|
Reference in New Issue
Block a user