8000 bug #25190 [HttpKernel] Keep legacy container files for concurrent re… · symfony/symfony@1f14f4d · GitHub
[go: up one dir, main page]

Skip to content

Commit 1f14f4d

Browse files
committed
bug #25190 [HttpKernel] Keep legacy container files for concurrent requests (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- [HttpKernel] Keep legacy container files for concurrent requests | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #25177 | License | MIT | Doc PR | - Because concurrent requests might still be using them, old container files should not be removed immediately, but on a next dump of the container. Commits ------- ee3b6fe [HttpKernel] Keep legacy container files for concurrent requests
2 parents 3c8ff5e + ee3b6fe commit 1f14f4d

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,19 @@ protected function initializeContainer()
644644
return;
645645
}
646646

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

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

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

Lines 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