Skip to content

Commit

Permalink
bug #51969 [FrameworkBundle] Fix calling Kernel::warmUp() when runn…
Browse files Browse the repository at this point in the history
…ing `cache:warmup` (nicolas-grekas)

This PR was merged into the 5.4 branch.

Discussion
----------

[FrameworkBundle] Fix calling `Kernel::warmUp()` when running `cache:warmup`

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT

Maps to https://github.com/symfony/symfony/blob/e86d26abd07187d5ec5b2d780cfd1d872d57fe2a/src/Symfony/Component/HttpKernel/Kernel.php#L581-L587

Commits
-------

f10c2cc [FrameworkBundle] Fix calling Kernel::warmUp() when running cache:warmup
  • Loading branch information
nicolas-grekas committed Oct 12, 2023
2 parents 20ea2ae + f10c2cc commit 4290999
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\DependencyInjection\Dumper\Preloader;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate;
use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;

/**
* Warmup the cache.
Expand Down Expand Up @@ -73,8 +74,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if (!$input->getOption('no-optional-warmers')) {
$this->cacheWarmer->enableOptionalWarmers();
}
$cacheDir = $kernel->getContainer()->getParameter('kernel.cache_dir');

$preload = $this->cacheWarmer->warmUp($cacheDir = $kernel->getContainer()->getParameter('kernel.cache_dir'));
if ($kernel instanceof WarmableInterface) {
$kernel->warmUp($cacheDir);
}

$preload = $this->cacheWarmer->warmUp($cacheDir);

if ($preload && file_exists($preloadFile = $cacheDir.'/'.$kernel->getContainer()->getParameter('kernel.container_class').'.preload.php')) {
Preloader::append($preloadFile, $preload);
Expand Down

0 comments on commit 4290999

Please sign in to comment.