8000 [FrameworkBundle] Set the kernel.name properly after a cache warmup by jakzal · Pull Request #17183 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] Set the kernel.name properly after a cache warmup #17183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,18 @@ protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = tr
}

// fix references to kernel/container related classes
$search = $tempKernel->getName().ucfirst($tempKernel->getEnvironment());
$replace = $realKernel->getName().ucfirst($realKernel->getEnvironment());
foreach (Finder::create()->files()->name($search.'*')->in($warmupDir) as $file) {
$fileSearch = $tempKernel->getName().ucfirst($tempKernel->getEnvironment()).'*';
$search = array(
$tempKernel->getName().ucfirst($tempKernel->getEnvironment()),
sprintf('\'kernel.name\' => \'%s\'', $tempKernel->getName()),
sprintf('key="kernel.name">%s<', $tempKernel->getName()),
);
$replace = array(
$realKernel->getName().ucfirst($realKernel->getEnvironment()),
sprintf('\'kernel.name\' => \'%s\'', $realKernel->getName()),
sprintf('key="kernel.name">%s<', $realKernel->getName()),
);
foreach (Finder::create()->files()->name($fileSearch)->in($warmupDir) as $file) {
$content = str_replace($search, $replace, file_get_contents($file));
file_put_contents(str_replace($search, $replace, $file), $content);
unlink($file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,6 @@ public function testCacheIsFreshAfterCacheClearedWithWarmup()
}
}
$this->assertTrue($found, 'Kernel file should present as resource');
$this->assertRegExp(sprintf('/\'kernel.name\'\s*=>\s*\'%s\'/', $this->kernel->getName()), file_get_contents($containerFile), 'kernel.name is properly set on the dumped container');
}
}
0