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

Skip to content

Commit 752378c

Browse files
Merge branch '5.4' into 6.2
* 5.4: [FrameworkBundle] Generate caches consistently on successive run of `cache:clear` command
2 parents 670e0f3 + 6166fc4 commit 752378c

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);
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);
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($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);
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(string $warmupDir, string $realBuildDir, bool $enableOptionalWarmers = true)
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(string $warmupDir, string $realBuildDir, bool $enableOpt
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);
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(string $warmupDir, string $realBuildDir, bool $enableOpt
250238
}
251239
}
252240
}
241+
242+
private function warmupOptionals(string $realCacheDir): 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);
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