8000 [FrameworkBundle] Fix patching refs to the tmp warmup dir in files ge… · symfony/framework-bundle@5791a99 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5791a99

Browse files
[FrameworkBundle] Fix patching refs to the tmp warmup dir in files generated by optional cache warmers
1 parent 45e3acf commit 5791a99

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Command/CacheClearCommand.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
146146
}
147147
$this->warmupOptionals($useBuildDir ? $realCacheDir : $warmupDir, $warmupDir, $io);
148148
}
149+
150+
// fix references to cached files with the real cache directory name
151+
$search = [$warmupDir, str_replace('/', '\\/', $warmupDir), str_replace('\\', '\\\\', $warmupDir)];
152+
$replace = str_replace('\\', '/', $realBuildDir);
153+
foreach (Finder::create()->files()->in($warmupDir) as $file) {
154+
$content = str_replace($search, $replace, file_get_contents($file), $count);
155+
if ($count) {
156+
file_put_contents($file, $content);
157+
}
158+
}
149159
}
150160

151161
if (!$fs->exists($warmupDir.'/'.$containerDir)) {
@@ -227,16 +237,6 @@ private function warmup(string $warmupDir, string $realBuildDir): void
227237
throw new \LogicException('Calling "cache:clear" with a kernel that does not implement "Symfony\Component\HttpKernel\RebootableInterface" is not supported.');
228238
}
229239
$kernel->reboot($warmupDir);
230-
231-
// fix references to cached files with the real cache directory name
232-
$search = [$warmupDir, str_replace('\\', '\\\\', $warmupDir)];
233-
$replace = str_replace('\\', '/', $realBuildDir);
234-
foreach (Finder::create()->files()->in($warmupDir) as $file) {
235-
$content = str_replace($search, $replace, file_get_contents($file), $count);
236-
if ($count) {
237-
file_put_contents($file, $content);
238-
}
239-
}
240240
}
241241

242242
private function warmupOptionals(string $cacheDir, string $warmupDir, SymfonyStyle $io): void

0 commit comments

Comments
 (0)
0