From 41ac5c1446c380311ae923cd2d27f3ea6d655960 Mon Sep 17 00:00:00 2001 From: nod_ <nod_@598310.no-reply.drupal.org> Date: Tue, 30 Jul 2024 14:57:57 +0200 Subject: [PATCH] Issue #3461860 by catch, smustgrave: More efficient route lookup caching (cherry picked from commit da5f6215a9a258ec94010455281620a138ed8eae) --- core/lib/Drupal/Core/Routing/RouteProvider.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/lib/Drupal/Core/Routing/RouteProvider.php b/core/lib/Drupal/Core/Routing/RouteProvider.php index a0b4384ad7f4..951b057e6c94 100644 --- a/core/lib/Drupal/Core/Routing/RouteProvider.php +++ b/core/lib/Drupal/Core/Routing/RouteProvider.php @@ -169,6 +169,9 @@ public function getRouteCollectionForRequest(Request $request) { if ($cached = $this->cache->get($cid)) { $this->currentPath->setPath($cached->data['path'], $request); $request->query->replace($cached->data['query']); + if ($cached->data['routes'] === FALSE) { + return new RouteCollection(); + } return $cached->data['routes']; } else { @@ -183,7 +186,7 @@ public function getRouteCollectionForRequest(Request $request) { $cache_value = [ 'path' => $path, 'query' => $query_parameters, - 'routes' => $routes, + 'routes' => $routes->count() === 0 ? FALSE : $routes, ]; $this->cache->set($cid, $cache_value, CacheBackendInterface::CACHE_PERMANENT, ['route_match']); return $routes; -- GitLab