composer update
This commit is contained in:
35
vendor/symfony/routing/Router.php
vendored
35
vendor/symfony/routing/Router.php
vendored
@@ -97,6 +97,8 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
*/
|
||||
private $expressionLanguageProviders = [];
|
||||
|
||||
private static $cache = [];
|
||||
|
||||
/**
|
||||
* @param mixed $resource The main resource to load
|
||||
*/
|
||||
@@ -283,7 +285,7 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
return $this->matcher;
|
||||
}
|
||||
|
||||
$compiled = is_a($this->options['matcher_class'], CompiledUrlMatcher::class, true) && (UrlMatcher::class === $this->options['matcher_base_class'] || RedirectableUrlMatcher::class === $this->options['matcher_base_class']);
|
||||
$compiled = is_a($this->options['matcher_class'], CompiledUrlMatcher::class, true) && (UrlMatcher::class === $this->options['matcher_base_class'] || RedirectableUrlMatcher::class === $this->options['matcher_base_class']) && is_a($this->options['matcher_dumper_class'], CompiledUrlMatcherDumper::class, true);
|
||||
|
||||
if (null === $this->options['cache_dir'] || null === $this->options['matcher_cache_class']) {
|
||||
$routes = $this->getRouteCollection();
|
||||
@@ -319,7 +321,7 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
);
|
||||
|
||||
if ($compiled) {
|
||||
return $this->matcher = new $this->options['matcher_class'](require $cache->getPath(), $this->context);
|
||||
return $this->matcher = new $this->options['matcher_class'](self::getCompiledRoutes($cache->getPath()), $this->context);
|
||||
}
|
||||
|
||||
if (!class_exists($this->options['matcher_cache_class'], false)) {
|
||||
@@ -340,7 +342,7 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
return $this->generator;
|
||||
}
|
||||
|
||||
$compiled = is_a($this->options['generator_class'], CompiledUrlGenerator::class, true) && UrlGenerator::class === $this->options['generator_base_class'];
|
||||
$compiled = is_a($this->options['generator_class'], CompiledUrlGenerator::class, true) && UrlGenerator::class === $this->options['generator_base_class'] && is_a($this->options['generator_dumper_class'], CompiledUrlGeneratorDumper::class, true);
|
||||
|
||||
if (null === $this->options['cache_dir'] || null === $this->options['generator_cache_class']) {
|
||||
$routes = $this->getRouteCollection();
|
||||
@@ -363,7 +365,7 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
);
|
||||
|
||||
if ($compiled) {
|
||||
$this->generator = new $this->options['generator_class'](require $cache->getPath(), $this->context, $this->logger, $this->defaultLocale);
|
||||
$this->generator = new $this->options['generator_class'](self::getCompiledRoutes($cache->getPath()), $this->context, $this->logger, $this->defaultLocale);
|
||||
} else {
|
||||
if (!class_exists($this->options['generator_cache_class'], false)) {
|
||||
require_once $cache->getPath();
|
||||
@@ -390,8 +392,8 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
*/
|
||||
protected function getGeneratorDumperInstance()
|
||||
{
|
||||
// For BC, fallback to PhpGeneratorDumper if the UrlGenerator and UrlGeneratorDumper are not consistent with each other
|
||||
if (is_a($this->options['generator_class'], CompiledUrlGenerator::class, true) !== is_a($this->options['generator_dumper_class'], CompiledUrlGeneratorDumper::class, true)) {
|
||||
// For BC, fallback to PhpGeneratorDumper (which is the old default value) if the old UrlGenerator is used with the new default CompiledUrlGeneratorDumper
|
||||
if (!is_a($this->options['generator_class'], CompiledUrlGenerator::class, true) && is_a($this->options['generator_dumper_class'], CompiledUrlGeneratorDumper::class, true)) {
|
||||
return new PhpGeneratorDumper($this->getRouteCollection());
|
||||
}
|
||||
|
||||
@@ -403,8 +405,8 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
*/
|
||||
protected function getMatcherDumperInstance()
|
||||
{
|
||||
// For BC, fallback to PhpMatcherDumper if the UrlMatcher and UrlMatcherDumper are not consistent with each other
|
||||
if (is_a($this->options['matcher_class'], CompiledUrlMatcher::class, true) !== is_a($this->options['matcher_dumper_class'], CompiledUrlMatcherDumper::class, true)) {
|
||||
// For BC, fallback to PhpMatcherDumper (which is the old default value) if the old UrlMatcher is used with the new default CompiledUrlMatcherDumper
|
||||
if (!is_a($this->options['matcher_class'], CompiledUrlMatcher::class, true) && is_a($this->options['matcher_dumper_class'], CompiledUrlMatcherDumper::class, true)) {
|
||||
return new PhpMatcherDumper($this->getRouteCollection());
|
||||
}
|
||||
|
||||
@@ -434,4 +436,21 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
@trigger_error(sprintf('Option "%s" given to router %s is deprecated since Symfony 4.3.', $key, static::class), E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
private static function getCompiledRoutes(string $path): array
|
||||
{
|
||||
if ([] === self::$cache && \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))) {
|
||||
self::$cache = null;
|
||||
}
|
||||
|
||||
if (null === self::$cache) {
|
||||
return require $path;
|
||||
}
|
||||
|
||||
if (isset(self::$cache[$path])) {
|
||||
return self::$cache[$path];
|
||||
}
|
||||
|
||||
return self::$cache[$path] = require $path;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user