diff --git a/core/lib/Drupal/Core/Routing/CompiledRoute.php b/core/lib/Drupal/Core/Routing/CompiledRoute.php index ff76b11..4bc608c 100644 --- a/core/lib/Drupal/Core/Routing/CompiledRoute.php +++ b/core/lib/Drupal/Core/Routing/CompiledRoute.php @@ -68,7 +68,7 @@ public function __construct($fit, $pattern_outline, $num_parts, $staticPrefix, $ $this->fit = $fit; // Support case insensitive route matching by ensuring the pattern outline // is lowercase. - // @see \Drupal\Core\Routing\RouteProvider::getRoutesByPath + // @see \Drupal\Core\Routing\RouteProvider::getRoutesByPath() $this->patternOutline = Unicode::strtolower($pattern_outline); $this->numParts = $num_parts; } diff --git a/core/lib/Drupal/Core/Routing/RouteCompiler.php b/core/lib/Drupal/Core/Routing/RouteCompiler.php index 7185aa4..be17624 100644 --- a/core/lib/Drupal/Core/Routing/RouteCompiler.php +++ b/core/lib/Drupal/Core/Routing/RouteCompiler.php @@ -61,14 +61,14 @@ public static function compile(Route $route) { $symfony_compiled->getHostTokens(), $symfony_compiled->getHostVariables(), $symfony_compiled->getVariables() - ); + ); } /** * Returns the pattern outline. * * The pattern outline is the path pattern but normalized so that all - * placeholders are equal strings and default values are removed. + * placeholders are the string '%'. * * @param string $path * The path for which we want the normalized outline. diff --git a/core/lib/Drupal/Core/Routing/Router.php b/core/lib/Drupal/Core/Routing/Router.php index 861ccda..fc28b51 100644 --- a/core/lib/Drupal/Core/Routing/Router.php +++ b/core/lib/Drupal/Core/Routing/Router.php @@ -177,10 +177,10 @@ public function matchRequest(Request $request) { */ protected function matchCollection($pathinfo, RouteCollection $routes) { // Try a case sensitive match. - $match = $this->_matchCollection($pathinfo, $routes, TRUE); + $match = $this->doMatchCollection($pathinfo, $routes, TRUE); // Try a case in-sensitive match. - if ($match === NULL) { - $match = $this->_matchCollection($pathinfo, $routes, FALSE); + if ($match === NULL && $routes->count() > 0) { + $match = $this->doMatchCollection($pathinfo, $routes, FALSE); } return $match; } @@ -211,7 +211,7 @@ protected function matchCollection($pathinfo, RouteCollection $routes) { * @see \Symfony\Component\Routing\Matcher\UrlMatcher::matchCollection() * @see \Drupal\Core\Routing\RouteProvider::getRoutesByPath() */ - protected function _matchCollection($pathinfo, RouteCollection $routes, $case_sensitive) { + protected function doMatchCollection($pathinfo, RouteCollection $routes, $case_sensitive) { foreach ($routes as $name => $route) { $compiledRoute = $route->compile(); @@ -226,6 +226,7 @@ protected function _matchCollection($pathinfo, RouteCollection $routes, $case_se $hostMatches = array(); if ($compiledRoute->getHostRegex() && !preg_match($compiledRoute->getHostRegex(), $this->context->getHost(), $hostMatches)) { + $routes->remove($name); continue; } @@ -238,7 +239,7 @@ protected function _matchCollection($pathinfo, RouteCollection $routes, $case_se if (!in_array($method, $requiredMethods)) { $this->allow = array_merge($this->allow, $requiredMethods); - + $routes->remove($name); continue; } } @@ -250,6 +251,7 @@ protected function _matchCollection($pathinfo, RouteCollection $routes, $case_se } if (self::REQUIREMENT_MISMATCH === $status[0]) { + $routes->remove($name); continue; }