Skip to content

Commit dff609f

Browse files
committed
[FrameworkBundle][CacheWarmupCommand] Append files to preload
1 parent 273a643 commit dff609f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Command/CacheClearCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
120120
$warmer->enableOnlyOptionalWarmers();
121121
$preload = (array) $warmer->warmUp($realCacheDir);
122122

123-
if (file_exists($preloadFile = $realCacheDir.'/'.$kernel->getContainer()->getParameter('kernel.container_class').'.preload.php')) {
123+
if ($preload && file_exists($preloadFile = $realCacheDir.'/'.$kernel->getContainer()->getParameter('kernel.container_class').'.preload.php')) {
124124
Preloader::append($preloadFile, $preload);
125125
}
126126
}
@@ -200,7 +200,7 @@ private function warmup(string $warmupDir, string $realCacheDir, bool $enableOpt
200200
$warmer->enableOnlyOptionalWarmers();
201201
$preload = (array) $warmer->warmUp($warmupDir);
202202

203-
if (file_exists($preloadFile = $warmupDir.'/'.$kernel->getContainer()->getParameter('kernel.container_class').'.preload.php')) {
203+
if ($preload && file_exists($preloadFile = $warmupDir.'/'.$kernel->getContainer()->getParameter('kernel.container_class').'.preload.php')) {
204204
Preloader::append($preloadFile, $preload);
205205
}
206206
}

Command/CacheWarmupCommand.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Console\Input\InputOption;
1717
use Symfony\Component\Console\Output\OutputInterface;
1818
use Symfony\Component\Console\Style\SymfonyStyle;
19+
use Symfony\Component\DependencyInjection\Dumper\Preloader;
1920
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate;
2021

2122
/**
@@ -77,7 +78,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7778
$this->cacheWarmer->enableOptionalWarmers();
7879
}
7980

80-
$this->cacheWarmer->warmUp($kernel->getContainer()->getParameter('kernel.cache_dir'));
81+
$preload = $this->cacheWarmer->warmUp($cacheDir = $kernel->getContainer()->getParameter('kernel.cache_dir'));
82+
83+
if ($preload && file_exists($preloadFile = $cacheDir.'/'.$kernel->getContainer()->getParameter('kernel.container_class').'.preload.php')) {
84+
Preloader::append($preloadFile, $preload);
85+
}
8186

8287
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully warmed.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
8388

0 commit comments

Comments
 (0)