Problem/Motivation
After updating Drupal from version 10.2.7 to version 10.30, a 404 error occurred!
Bilingual website pl/en
the https//mydomain/en version works fine
the https//my_domain version (by default pl as the domain's primary language) shows a 404 error after clearing the cache.
Warning: Undefined array key "route:[language]=pl:[query_parameters]=:/ " in Drupal\Core\Cache\DatabaseBackend->getMultiple() (line 155 of core/lib/Drupal/Core/Cache/DatabaseBackend.php).
Drupal\Core\Cache\DatabaseBackend->getMultiple(Array, ) (Line: 126)
Drupal\Core\Cache\DatabaseBackend->get('route:[language]=pl:[query_parameters]=:/') (Line: 169)
Drupal\Core\Routing\RouteProvider->getRouteCollectionForRequest(Object) (Line: 252)
Drupal\Core\Routing\Router->getInitialRouteCollection(Object) (Line: 142)
Drupal\Core\Routing\Router->matchRequest(Object) (Line: 90)
Drupal\Core\Routing\AccessAwareRouter->matchRequest(Object) (Line: 105)
Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest(Object, 'kernel.request', Object)
call_user_func(Array, Object, 'kernel.request', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.request') (Line: 157)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
P.S.
There is no cache problem with a single-language website.
I think the problem is that garbage collection corrupts the path to the home-page
does not allow null values in the main language.
After entering the language prefix it works fine.
But I guess that's not the point, because it destroys the links already provided.
Steps to reproduce
Install the standard profile.
TRUNCATE cache_data;
Visit https://drupal-dev.ddev.site/
Then https://drupal-dev.ddev.site/:%20
Without the MR, you will get a 404 and see the following three cache entries:
MariaDB [db]> SELECT cid FROM cache_data WHERE cid LIKE 'route:%';
+-----------------------------------------------------+
| cid |
+-----------------------------------------------------+
| route:[language]=en:[query_parameters]=:/ |
| route:[language]=en:[query_parameters]=:/%20 |
| route:[language]=en:[query_parameters]=:/system/404 |
+-----------------------------------------------------+
With the MR you will get a 200 on the path with %20 at the end, and there'll be a single cache entry:
MariaDB [db]> SELECT cid FROM cache_data WHERE cid LIKE 'route:%';
+-------------------------------------------+
| cid |
+-------------------------------------------+
| route:[language]=en:[query_parameters]=:/ |
+-------------------------------------------+
1 row in set (0.001 sec)
Proposed resolution
While there are not steps to reproduce yet, route lookup caching is inconsistent for urlencoded URLs, due to the way PathProcessorDecode happens during routing after the cache ID is created.
Instead of a path processor, we need to normalize the incoming path with urldecode directly in RouteProvider.
This means that https://example.com/%20 will consistently return a 200 (for the front page) instead of a 404. We might want a follow-up to redirect trailing urlencoded spaces in .htaccess
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet