diff --git a/core/lib/Drupal/Core/Routing/RouteProvider.php b/core/lib/Drupal/Core/Routing/RouteProvider.php index dbab344..170c10c 100644 --- a/core/lib/Drupal/Core/Routing/RouteProvider.php +++ b/core/lib/Drupal/Core/Routing/RouteProvider.php @@ -135,9 +135,9 @@ public function getRouteCollectionForRequest(Request $request) { // routes. $cid = 'route:' . $request->getPathInfo() . ':' . $request->getQueryString(); if ($cached = $this->cache->get($cid)) { - $this->currentPath->setPath($cached->data[0], $request); - $request->query->replace($cached->data[1]); - return $cached->data[2]; + $this->currentPath->setPath($cached->data['path'], $request); + $request->query->replace($cached->data['query']); + return $cached->data['routes']; } else { $path = trim($request->getPathInfo(), '/'); @@ -146,7 +146,12 @@ public function getRouteCollectionForRequest(Request $request) { // Incoming path processors may also set query parameters. $query_parameters = $request->query->all(); $routes = $this->getRoutesByPath('/' . rtrim($path, '/')); - $this->cache->set($cid, ['/' . $path, $query_parameters, $routes], CacheBackendInterface::CACHE_PERMANENT, ['route_match']); + $cache_value = [ + 'path' => '/' . $path, + 'query' => $query_parameters, + 'routes' => $routes, + ]; + $this->cache->set($cid, $cache_value, CacheBackendInterface::CACHE_PERMANENT, ['route_match']); return $routes; } } diff --git a/core/modules/system/src/Tests/Routing/RouteProviderTest.php b/core/modules/system/src/Tests/Routing/RouteProviderTest.php index 9199082..96c5100 100644 --- a/core/modules/system/src/Tests/Routing/RouteProviderTest.php +++ b/core/modules/system/src/Tests/Routing/RouteProviderTest.php @@ -405,9 +405,9 @@ public function testRouteCaching() { $provider->getRouteCollectionForRequest($request); $cache = $this->cache->get('route:/path/add/one:'); - $this->assertEqual('/path/add/one', $cache->data[0]); - $this->assertEqual([], $cache->data[1]); - $this->assertEqual(3, count($cache->data[2])); + $this->assertEqual('/path/add/one', $cache->data['path']); + $this->assertEqual([], $cache->data['query']); + $this->assertEqual(3, count($cache->data['routes'])); // A path with query parameters. $path = '/path/add/one?foo=bar'; @@ -415,9 +415,9 @@ public function testRouteCaching() { $provider->getRouteCollectionForRequest($request); $cache = $this->cache->get('route:/path/add/one:foo=bar'); - $this->assertEqual('/path/add/one', $cache->data[0]); - $this->assertEqual(['foo' => 'bar'], $cache->data[1]); - $this->assertEqual(3, count($cache->data[2])); + $this->assertEqual('/path/add/one', $cache->data['path']); + $this->assertEqual(['foo' => 'bar'], $cache->data['query']); + $this->assertEqual(3, count($cache->data['routes'])); // A path with placeholders. $path = '/path/1/one'; @@ -425,9 +425,9 @@ public function testRouteCaching() { $provider->getRouteCollectionForRequest($request); $cache = $this->cache->get('route:/path/1/one:'); - $this->assertEqual('/path/1/one', $cache->data[0]); - $this->assertEqual([], $cache->data[1]); - $this->assertEqual(2, count($cache->data[2])); + $this->assertEqual('/path/1/one', $cache->data['path']); + $this->assertEqual([], $cache->data['query']); + $this->assertEqual(2, count($cache->data['routes'])); // A path with a path alias. /** @var \Drupal\Core\Path\AliasStorageInterface $path_storage */ @@ -442,9 +442,9 @@ public function testRouteCaching() { $provider->getRouteCollectionForRequest($request); $cache = $this->cache->get('route:/path/add-one:'); - $this->assertEqual('/path/add/one', $cache->data[0]); - $this->assertEqual([], $cache->data[1]); - $this->assertEqual(3, count($cache->data[2])); + $this->assertEqual('/path/add/one', $cache->data['path']); + $this->assertEqual([], $cache->data['query']); + $this->assertEqual(3, count($cache->data['routes'])); } /**