Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c86504e

Browse filesBrowse files
[HttpKernel] Keep legacy container files for concurrent requests
1 parent a19d1e5 commit c86504e
Copy full SHA for c86504e

File tree

Expand file treeCollapse file tree

2 files changed

+15
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+15
-3
lines changed

‎src/Symfony/Component/HttpKernel/Kernel.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Kernel.php
+13-2Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,8 +643,19 @@ protected function initializeContainer()
643643
return;
644644
}
645645

646-
if ($oldContainer && get_class($this->container) !== $oldContainer->name) {
647-
(new Filesystem())->remove(dirname($oldContainer->getFileName()));
646+
if ($oldContainer) {
647+
// Because concurrent requests might still be using them,
648+
// old container files are not removed immediately,
649+
// but on a next dump of the container.
650+
$oldContainerDir = dirname($oldContainer->getFileName());
651+
foreach (glob(dirname($oldContainerDir).'/*.legacyContainer') as $legacyContainer) {
652+
if (@unlink($legacyContainer)) {
653+
(new Filesystem())->remove(substr($legacyContainer, 0, -16));
654+
}
655+
}
656+
if ($oldContainer && get_class($this->container) !== $oldContainer->name) {
657+
touch($oldContainerDir.'.legacyContainer');
658+
}
648659
}
649660

650661
if ($this->container->has('cache_warmer')) {

‎src/Symfony/Component/HttpKernel/Tests/KernelTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/KernelTest.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,8 @@ public function testKernelReset()
832832
$kernel->boot();
833833

834834
$this->assertTrue(get_class($kernel->getContainer()) !== $containerClass);
835-
$this->assertFileNotExists($containerFile);
835+
$this->assertFileExists($containerFile);
836+
$this->assertFileExists(dirname($containerFile).'.legacyContainer');
836837
}
837838

838839
public function testKernelPass()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.