8000 bug #17183 [FrameworkBundle] Set the kernel.name properly after a cac… · symfony/symfony@19a6335 · GitHub
[go: up one dir, main page]

Skip to content

Commit 19a6335

Browse files
committed
bug #17183 [FrameworkBundle] Set the kernel.name properly after a cache warmup (jakzal)
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #17183). Discussion ---------- [FrameworkBundle] Set the kernel.name properly after a cache warmup | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #16180 | License | MIT | Doc PR | - Commits ------- 1438b9a [FrameworkBundle] Set the kernel.name properly after a cache warmup
2 parents 5a9c1b5 + 1438b9a commit 19a6335

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,18 @@ protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = tr
144144
}
145145

146146
// fix references to kernel/container related classes
147-
$search = $tempKernel->getName().ucfirst($tempKernel->getEnvironment());
148-
$replace = $realKernel->getName().ucfirst($realKernel->getEnvironment());
149-
foreach (Finder::create()->files()->name($search.'*')->in($warmupDir) as $file) {
147+
$fileSearch = $tempKernel->getName().ucfirst($tempKernel->getEnvironment()).'*';
148+
$search = array(
149+
$tempKernel->getName().ucfirst($tempKernel->getEnvironment()),
150+
sprintf('\'kernel.name\' => \'%s\'', $tempKernel->getName()),
151+
sprintf('key="kernel.name">%s<', $tempKernel->getName()),
152+
);
153+
$replace = array(
154+
$realKernel->getName().ucfirst($realKernel->getEnvironment()),
155+
sprintf('\'kernel.name\' => \'%s\'', $realKernel->getName()),
156+
sprintf('key="kernel.name">%s<', $realKernel->getName()),
157+
);
158+
foreach (Finder::create()->files()->name($fileSearch)->in($warmupDir) as $file) {
150159
$content = str_replace($search, $replace, file_get_contents($file));
151160
file_put_contents(str_replace($search, $replace, $file), $content);
152161
unlink($file);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,6 @@ public function testCacheIsFreshAfterCacheClearedWithWarmup()
8383
}
8484
}
8585
$this->assertTrue($found, 'Kernel file should present as resource');
86+
$this->assertRegExp(sprintf('/\'kernel.name\'\s*=>\s*\'%s\'/', $this->kernel->getName()), file_get_contents($containerFile), 'kernel.name is properly set on the dumped container');
8687
}
8788
}

0 commit comments

Comments
 (0)
0