Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8e93517

Browse files
bug #50475 [FrameworkBundle] Prevent cache:clear to lose files on subsequent 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 ------- 61bdd80 [FrameworkBundle] Prevent `cache:clear` to lose files on subsequent runs
2 parents e11b3a3 + 61bdd80 commit 8e93517

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
137137
if ($output->isVerbose()) {
138138
$io->comment('Warming up optional cache...');
139139
}
140-
$this->warmupOptionals($realCacheDir);
140+
$this->warmupOptionals($realCacheDir, $realBuildDir);
141141
}
142142
} else {
143143
$fs->mkdir($warmupDir);
@@ -152,7 +152,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
152152
if ($output->isVerbose()) {
153153
$io->comment('Warming up optional cache...');
154154
}
155-
$this->warmupOptionals($realCacheDir);
155+
$this->warmupOptionals($useBuildDir ? $realCacheDir : $warmupDir, $warmupDir);
156156
}
157157
}
158158

@@ -247,15 +247,15 @@ private function warmup(string $warmupDir, string $realBuildDir): void
247247
}
248248
}
249249

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

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

0 commit comments

Comments
 (0)