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 3c5841d

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

File tree

2 files changed

+12
-2
lines changed
Filter options

2 files changed

+12
-2
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Kernel.php
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,16 @@ protected function initializeContainer()
644644
}
645645

646646
if ($oldContainer && get_class($this->container) !== $oldContainer->name) {
647-
(new Filesystem())->remove(dirname($oldContainer->getFileName()));
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+
touch($oldContainerDir.'.legacyContainer');
648657
}
649658

650659
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.