Skip to content

Commit

Permalink
bug #50475 [FrameworkBundle] Prevent cache:clear to lose files on s…
Browse files Browse the repository at this point in the history
…ubsequent runs (Okhoshi)

This PR was merged into the 5.4 branch.

Discussion
----------

[FrameworkBundle] Prevent `cache:clear` to lose files on subsequent runs

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #50474
| License       | MIT
| Doc PR        | N/A

See #50474 for the details and reproduction information.

Commits
-------

61bdd80e2e [FrameworkBundle] Prevent `cache:clear` to lose files on subsequent runs
  • Loading branch information
nicolas-grekas committed Jul 7, 2023
2 parents 9f97162 + ee50ae4 commit 16626db
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Command/CacheClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ($output->isVerbose()) {
$io->comment('Warming up optional cache...');
}
$this->warmupOptionals($realCacheDir);
$this->warmupOptionals($realCacheDir, $realBuildDir);
}
} else {
$fs->mkdir($warmupDir);
Expand All @@ -152,7 +152,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ($output->isVerbose()) {
$io->comment('Warming up optional cache...');
}
$this->warmupOptionals($realCacheDir);
$this->warmupOptionals($useBuildDir ? $realCacheDir : $warmupDir, $warmupDir);
}
}

Expand Down Expand Up @@ -247,15 +247,15 @@ private function warmup(string $warmupDir, string $realBuildDir): void
}
}

private function warmupOptionals(string $realCacheDir): void
private function warmupOptionals(string $cacheDir, string $warmupDir): void
{
$kernel = $this->getApplication()->getKernel();
$warmer = $kernel->getContainer()->get('cache_warmer');
// non optional warmers already ran during container compilation
$warmer->enableOnlyOptionalWarmers();
$preload = (array) $warmer->warmUp($realCacheDir);
$preload = (array) $warmer->warmUp($cacheDir);

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

0 comments on commit 16626db

Please sign in to comment.