[HttpKernel] Don't clean legacy containers that are still loaded

This commit is contained in:
Nicolas Grekas 2018-04-26 13:28:24 +02:00
parent ea25fec603
commit be8dbc3660
1 changed files with 4 additions and 2 deletions

View File

@ -670,9 +670,11 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
// Because concurrent requests might still be using them,
// old container files are not removed immediately,
// but on a next dump of the container.
static $legacyContainers = array();
$oldContainerDir = dirname($oldContainer->getFileName());
foreach (glob(dirname($oldContainerDir).'/*.legacy') as $legacyContainer) {
if ($oldContainerDir.'.legacy' !== $legacyContainer && @unlink($legacyContainer)) {
$legacyContainers[$oldContainerDir.'.legacy'] = true;
foreach (glob(dirname($oldContainerDir).DIRECTORY_SEPARATOR.'*.legacy') as $legacyContainer) {
if (!isset($legacyContainers[$legacyContainer]) && @unlink($legacyContainer)) {
(new Filesystem())->remove(substr($legacyContainer, 0, -7));
}
}