bug #27061 [HttpKernel] Don't clean legacy containers that are still loaded (nicolas-grekas)

This PR was merged into the 3.4 branch.

Discussion
----------

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

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  |
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #27053
| License       | MIT
| Doc PR        | -

Commits
-------

be8dbc3 [HttpKernel] Don't clean legacy containers that are still loaded
This commit is contained in:
Nicolas Grekas 2018-04-26 17:06:18 +02:00
commit b8c15383cf
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));
}
}