File tree 2 files changed +15
-3
lines changed
src/Symfony/Component/HttpKernel
2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -643,8 +643,19 @@ protected function initializeContainer()
643
643
return ;
644
644
}
645
645
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 (get_class ($ this ->container ) !== $ oldContainer ->name ) {
657
+ touch ($ oldContainerDir .'.legacyContainer ' );
658
+ }
648
659
}
649
660
650
661
if ($ this ->container ->has ('cache_warmer ' )) {
Original file line number Diff line number Diff line change @@ -832,7 +832,8 @@ public function testKernelReset()
832
832
$ kernel ->boot ();
833
833
834
834
$ this ->assertTrue (get_class ($ kernel ->getContainer ()) !== $ containerClass );
835
- $ this ->assertFileNotExists ($ containerFile );
835
+ $ this ->assertFileExists ($ containerFile );
836
+ $ this ->assertFileExists (dirname ($ containerFile ).'.legacyContainer ' );
836
837
}
837
838
838
839
public function testKernelPass ()
You can’t perform that action at this time.
0 commit comments