Skip to content

Commit 34b0eca

Browse files
committed
minor symfony#25176 [HttpKernel] Better handling of legacy cache (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- [HttpKernel] Better handling of legacy cache | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | on | Tests pass? | yes | Fixed tickets | symfony#25175 | License | MIT | Doc PR | - Even if this is edge case, it should improve DX when moving to 3.4 (I already experienced this issue myself :) ) Commits ------- 3a873f8 [HttpKernel] Better handling of legacy cache
2 parents a19d1e5 + 3a873f8 commit 34b0eca

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,11 @@ protected function initializeContainer()
581581
$class = $this->getContainerClass();
582582
$cacheDir = $this->warmupDir ?: $this->getCacheDir();
583583
$cache = new ConfigCache($cacheDir.'/'.$class.'.php', $this->debug);
584-
$fresh = true;
585-
if (!$cache->isFresh()) {
584+
if ($fresh = $cache->isFresh()) {
585+
$this->container = require $cache->getPath();
586+
$fresh = \is_object($this->container);
587+
}
588+
if (!$fresh) {
586589
if ($this->debug) {
587590
$collectedLogs = array();
588591
$previousHandler = set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
@@ -632,11 +635,9 @@ protected function initializeContainer()
632635
$oldContainer = file_exists($cache->getPath()) && is_object($oldContainer = @include $cache->getPath()) ? new \ReflectionClass($oldContainer) : false;
633636

634637
$this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());
635-
636-
$fresh = false;
638+
$this->container = require $cache->getPath();
637639
}
638640

639-
$this->container = require $cache->getPath();
640641
$this->container->set('kernel', $this);
641642

642643
if ($fresh) {

0 commit comments

Comments
 (0)