8000 [HttpKernel] Remove old container files · symfony/symfony@8701702 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8701702

Browse files
[HttpKernel] Remove old container files
1 parent eeaea83 commit 8701702

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,11 @@ protected function initializeContainer()
584584
file_put_contents($this->getCacheDir().'/'.$class.'Compiler.log', null !== $container ? implode("\n", $container->getCompiler()->getLog()) : '');
585585
}
586586
}
587+
588+
if ($oldContainer = file_exists($cache->getPath()) ? @include $cache->getPath() : false) {
589+
$oldContainer = new \ReflectionClass($oldContainer);
590+
}
591+
587592
$this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());
588593

589594
$fresh = false;
@@ -592,7 +597,15 @@ protected function initializeContainer()
592597
$this->container = require $cache->getPath();
593598
$this->container->set('kernel', $this);
594599

595-
if (!$fresh && $this->container->has('cache_warmer')) {
600+
if ($fresh) {
601+
return;
602+
}
603+
604+
if ($oldContainer && get_class($this->container) !== $oldContainer->name) {
605+
(new Filesystem())->remove(dirname($oldContainer->getFileName()));
606+
}
607+
608+
if ($this->container->has('cache_warmer')) {
596609
$this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir'));
597610
}
598611
}

0 commit comments

Comments
 (0)
0