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.
8000 Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[FrameworkBundle] Set the kernel.name properly after a cache warmup
  • Loading branch information
jakzal committed Dec 30, 2015
commit 01d23ee66f132466cf198291192b498a8d2a6c8d
15 changes: 12 additions & 3 deletions src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php
< 8000 td id="diff-9cd0d94f17905dec06f9ed7fb21a57fcaf2ef72a131aca678da8bc1144061779R160" data-line-number="160" class="blob-num blob-num-context js-linkable-line-number js-blob-rnum">
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