8000 Merge branch '6.2' into 6.3 · symfony/symfony@eb3e308 · GitHub
[go: up one dir, main page]

Skip to content

Commit eb3e308

Browse files
Merge branch '6.2' into 6.3
* 6.2: [FrameworkBundle] Generate caches consistently on successive run of `cache:clear` command
2 parents 8c637a5 + 752378c commit eb3e308

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

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

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
129129
if ($output->isVerbose()) {
130130
$io->comment('Warming up optional cache...');
131131
}
132-
$warmer = $kernel->getContainer()->get('cache_warmer');
133-
// non optional warmers already ran during container compilation
134-
$warmer->enableOnlyOptionalWarmers();
135-
$preload = (array) $warmer->warmUp($realCacheDir, $io);
136-
137-
if ($preload && file_exists($preloadFile = $realCacheDir.'/'.$kernel->getContainer()->getParameter('kernel.container_class').'.preload.php')) {
138-
Preloader::append($preloadFile, $preload);
139-
}
132+
$this->warmupOptionals($realCacheDir, $io);
140133
}
141134
} else {
142135
$fs->mkdir($warmupDir);
@@ -145,7 +138,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
145138
if ($output->isVerbose()) {
146139
$io->comment('Warming up cache...');
147140
}
148-
$this->warmup($io, $warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));
141+
$this->warmup($warmupDir, $realBuildDir);
142+
143+
if (!$input->getOption('no-optional-warmers')) {
144+
if ($output->isVerbose()) {
145+
$io->comment('Warming up optional cache...');
146+
}
147+
$this->warmupOptionals($realCacheDir, $io);
148+
}
149149
}
150150

151151
if (!$fs->exists($warmupDir.'/'.$containerDir)) {
@@ -219,7 +219,7 @@ private function isNfs(string $dir): bool
219219
return false;
220220
}
221221

222-
private function warmup(SymfonyStyle $io, string $warmupDir, string $realBuildDir, bool $enableOptionalWarmers = true): void
222+
private function warmup(string $warmupDir, string $realBuildDir): void
223223
{
224224
// create a temporary kernel
225225
$kernel = $this->getApplication()->getKernel();
@@ -228,18 +228,6 @@ private function warmup(SymfonyStyle $io, string $warmupDir, string $realBuildDi
228228
}
229229
$kernel->reboot($warmupDir);
230230

231-
// warmup temporary dir
232-
if ($enableOptionalWarmers) {
233-
$warmer = $kernel->getContainer()->get('cache_warmer');
234-
// non optional warmers already ran during container compilation
235-
$warmer->enableOnlyOptionalWarmers();
236-
$preload = (array) $warmer->warmUp($warmupDir, $io);
237-
238-
if ($preload && file_exists($preloadFile = $warmupDir.'/'.$kernel->getContainer()->getParameter('kernel.container_class').'.preload.php')) {
239-
Preloader::append($preloadFile, $preload);
240-
}
241-
}
242-
243231
// fix references to cached files with the real cache directory name
244232
$search = [$warmupDir, str_replace('\\', '\\\\', $warmupDir)];
245233
$replace = str_replace('\\', '/', $realBuildDir);
@@ -250,4 +238,17 @@ private function warmup(SymfonyStyle $io, string $warmupDir, string $realBuildDi
250238
}
251239
}
252240
}
241+
242+
private function warmupOptionals(string $realCacheDir, SymfonyStyle $io): void
243+
{
244+
$kernel = $this->getApplication()->getKernel();
245+
$warmer = $kernel->getContainer()->get('cache_warmer');
246+
// non optional warmers already ran during container compilation
247+
$warmer->enableOnlyOptionalWarmers();
248+
$preload = (array) $warmer->warmUp($realCacheDir, $io);
249+
250+
if ($preload && file_exists($preloadFile = $realCacheDir.'/'.$kernel->getContainer()->getParameter('kernel.container_class').'.preload.php')) {
251+
Preloader::append($preloadFile, $preload);
252+
}
253+
}
253254
}

0 commit comments

Comments
 (0)
0