[HttpKernel] dont check cache freshness more than once per process

This commit is contained in:
Nicolas Grekas 2019-11-15 16:19:43 +01:00
parent 2a91f28ed4
commit 7f9556ce19
1 changed files with 5 additions and 1 deletions

View File

@ -74,6 +74,8 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
private $requestStackSize = 0;
private $resetServices = false;
private static $freshCache = [];
const VERSION = '4.4.0-DEV';
const VERSION_ID = 40400;
const MAJOR_VERSION = 4;
@ -511,7 +513,9 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
$errorLevel = error_reporting(\E_ALL ^ \E_WARNING);
try {
if (file_exists($cachePath) && \is_object($this->container = include $cachePath) && (!$this->debug || $cache->isFresh())) {
if (file_exists($cachePath) && \is_object($this->container = include $cachePath)
&& (!$this->debug || (self::$freshCache[$k = $cachePath.'.'.$this->environment] ?? self::$freshCache[$k] = $cache->isFresh()))
) {
$this->container->set('kernel', $this);
error_reporting($errorLevel);