diff options
| author | Greg Roach <fisharebest@webtrees.net> | 2019-12-20 13:15:07 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@webtrees.net> | 2019-12-20 13:15:07 +0000 |
| commit | d6d267bde52d522e3889574798ca4315da9009b4 (patch) | |
| tree | 9022d10a8c25bea8e8a981e1a08d7e1152bd9f5c /vendor/symfony/cache/Traits | |
| parent | 23945a1e9b4e73aa11106918ff7a830315c0b826 (diff) | |
| download | webtrees-d6d267bde52d522e3889574798ca4315da9009b4.tar.gz webtrees-d6d267bde52d522e3889574798ca4315da9009b4.tar.bz2 webtrees-d6d267bde52d522e3889574798ca4315da9009b4.zip | |
Update vendor dependencies
Diffstat (limited to 'vendor/symfony/cache/Traits')
| -rw-r--r-- | vendor/symfony/cache/Traits/PhpArrayTrait.php | 11 | ||||
| -rw-r--r-- | vendor/symfony/cache/Traits/PhpFilesTrait.php | 33 |
2 files changed, 34 insertions, 10 deletions
diff --git a/vendor/symfony/cache/Traits/PhpArrayTrait.php b/vendor/symfony/cache/Traits/PhpArrayTrait.php index 89dd8100ba..6e7c72ca7d 100644 --- a/vendor/symfony/cache/Traits/PhpArrayTrait.php +++ b/vendor/symfony/cache/Traits/PhpArrayTrait.php @@ -30,6 +30,8 @@ trait PhpArrayTrait private $keys; private $values; + private static $valuesCache = []; + /** * Store an array of cached values. * @@ -116,6 +118,7 @@ EOF; unset($serialized, $value, $dump); @rename($tmpFile, $this->file); + unset(self::$valuesCache[$this->file]); $this->initialize(); } @@ -133,6 +136,7 @@ EOF; $this->keys = $this->values = []; $cleared = @unlink($this->file) || !file_exists($this->file); + unset(self::$valuesCache[$this->file]); if ($this->pool instanceof AdapterInterface) { return $this->pool->clear($prefix) && $cleared; @@ -146,12 +150,15 @@ EOF; */ private function initialize() { - if (!file_exists($this->file)) { + if (isset(self::$valuesCache[$this->file])) { + $values = self::$valuesCache[$this->file]; + } elseif (!file_exists($this->file)) { $this->keys = $this->values = []; return; + } else { + $values = self::$valuesCache[$this->file] = (include $this->file) ?: [[], []]; } - $values = (include $this->file) ?: [[], []]; if (2 !== \count($values) || !isset($values[0], $values[1])) { $this->keys = $this->values = []; diff --git a/vendor/symfony/cache/Traits/PhpFilesTrait.php b/vendor/symfony/cache/Traits/PhpFilesTrait.php index 41ff8bdd07..05b9d88433 100644 --- a/vendor/symfony/cache/Traits/PhpFilesTrait.php +++ b/vendor/symfony/cache/Traits/PhpFilesTrait.php @@ -35,12 +35,13 @@ trait PhpFilesTrait private $files = []; private static $startTime; + private static $valuesCache = []; public static function isSupported() { self::$startTime = self::$startTime ?? $_SERVER['REQUEST_TIME'] ?? time(); - return \function_exists('opcache_invalidate') && ('cli' !== \PHP_SAPI || filter_var(ini_get('opcache.enable_cli'), FILTER_VALIDATE_BOOLEAN)) && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN); + return \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), FILTER_VALIDATE_BOOLEAN)); } /** @@ -100,7 +101,6 @@ trait PhpFilesTrait } elseif (!\is_object($value)) { $values[$id] = $value; } elseif (!$value instanceof LazyValue) { - // calling a Closure is for @deprecated BC and should be removed in Symfony 5.0 $values[$id] = $value(); } elseif (false === $values[$id] = include $value->file) { unset($values[$id], $this->values[$id]); @@ -123,14 +123,20 @@ trait PhpFilesTrait try { $file = $this->files[$id] ?? $this->files[$id] = $this->getFile($id); - if (\is_array($expiresAt = include $file)) { + if (isset(self::$valuesCache[$file])) { + [$expiresAt, $this->values[$id]] = self::$valuesCache[$file]; + } elseif (\is_array($expiresAt = include $file)) { + if ($this->appendOnly) { + self::$valuesCache[$file] = $expiresAt; + } + [$expiresAt, $this->values[$id]] = $expiresAt; } elseif ($now < $expiresAt) { $this->values[$id] = new LazyValue($file); } if ($now >= $expiresAt) { - unset($this->values[$id], $missingIds[$k]); + unset($this->values[$id], $missingIds[$k], self::$valuesCache[$file]); } } catch (\ErrorException $e) { unset($missingIds[$k]); @@ -159,7 +165,13 @@ trait PhpFilesTrait $file = $this->files[$id] ?? $this->files[$id] = $this->getFile($id); $getExpiry = true; - if (\is_array($expiresAt = include $file)) { + if (isset(self::$valuesCache[$file])) { + [$expiresAt, $value] = self::$valuesCache[$file]; + } elseif (\is_array($expiresAt = include $file)) { + if ($this->appendOnly) { + self::$valuesCache[$file] = $expiresAt; + } + [$expiresAt, $value] = $expiresAt; } elseif ($this->appendOnly) { $value = new LazyValue($file); @@ -213,12 +225,14 @@ trait PhpFilesTrait $encodedKey = rawurlencode($key); - if (!$isStaticValue) { + if ($isStaticValue) { + $value = "return [{$expiry}, {$value}];"; + } elseif ($this->appendOnly) { + $value = "return [{$expiry}, static function () { return {$value}; }];"; + } else { // We cannot use a closure here because of https://bugs.php.net/76982 $value = str_replace('\Symfony\Component\VarExporter\Internal\\', '', $value); $value = "namespace Symfony\Component\VarExporter\Internal;\n\nreturn \$getExpiry ? {$expiry} : {$value};"; - } else { - $value = "return [{$expiry}, {$value}];"; } $file = $this->files[$key] = $this->getFile($key, true); @@ -229,6 +243,7 @@ trait PhpFilesTrait @opcache_invalidate($file, true); @opcache_compile_file($file); } + unset(self::$valuesCache[$file]); } if (!$ok && !is_writable($this->directory)) { @@ -262,6 +277,8 @@ trait PhpFilesTrait protected function doUnlink($file) { + unset(self::$valuesCache[$file]); + if (self::isSupported()) { @opcache_invalidate($file, true); } |
