Problem/Motivation
If you add a multilingual menu link with internal:/some-path-alias uri in a menu, clearing the cache populates cache_data record with an incorrect RouteCollection routes.
For example if I have a Finnish node with path alias /broken-url-alias-test and manually add it (with the path, not with entity:node/X uri) to the menu and set menu link language to Finnish, clearing the cache generates the following route collection for cid = route:/broken-url-alias-test::
a:3:{s:4:"path";s:17:"/broken-url-alias";s:5:"query";a:0:{}s:6:"routes";O:41:"Symfony\Component\Routing\RouteCollection":2:{s:49:" Symfony\Component\Routing\RouteCollection routes";a:0:{}s:52:" Symfony\Component\Routing\RouteCollection resources";a:0:{}}}
and visiting the /broken-url-alias path will obviously result in 404 error.
If you manually delete the cache record, add anything to the url (like /broken-url-alias-test?1) or clear caches via ui when the ui language is same as the menu link language (fi.d8.local/admin/config/development/performance) it seems to work just fine.
Steps to Reproduce
1. Install all modules in Multilingual (language, locale, config_translation, content_translation)
2. Add Finnish language (or any other language)
3. Enable URL (domain) detection method, set language specific domains (fi.d8.local, d8.local etc.)
4. Enable "Content" and "Custom menu link" translation (/admin/config/regional/content-language)
5. Create a new (Finnish) node with an url alias (/broken-url-alias-test)
6. Add a new menu link to the footer menu with /broken-url-alias-test link and set language to Finnish
7. Flush caches and go to fi.d8.local/broken-url-alias-test
I'm not sure if this is specific to "Domain" language detection as this seems to sometimes happen with path prefix as well.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 2852303-5.patch | 3.05 KB | leksat |
Comments
Comment #2
leksat commentedThis probably caused not by menu links, but by the routing system in general - it seems like it does not count domains when caches routes.
My steps to reproduce:
- clean drupal 8.3.x (67a934e) installation, website with en. and ru. subdomains, domain based language detection
- create en node with url path alias "/test-en" => node is available at "en.example.com/test-en"
- clear caches
- access "ru.example.com/test-en" => 404
- access "en.example.com/test-en" => also 404
Comment #3
leksat commentedComment #5
leksat commentedComment #6
leksat commented@tuutti can you check if patch #5 fixes the bug for you?
Comment #7
tuutti commentedYou are right. It was easier to demonstrate this with menu links because the route cache for menu links will be re-populated during the cache clear.
It does, thank you!
This however will cause at least two different issues:
Comment #8
leksat commented@tuutti,
i'm not sure what you mean... Can you point me to the code where this happens?
Comment #9
tuutti commented\Drupal\Core\Routing\RouteProvider::getRouteCollectionForRequest().I think it is initialized by
\Drupal\Core\Menu\MenuLinkManager::rebuild()which eventually will call getRouteCollectionForRequest() for every menu link.You can confirm this by placing some menu links and clearing the cache and then query cache data table.
Comment #11
hctomSorry to crosspost a little, but I just created another issue that might have the same root cause: #2915190: Menu links losing active trail when not edited in path alias language (sorry for the bad title, but I did not really know how to title it because of its complexicity, hehe). Currently I only added detailed steps to reproduce losing the menu active trail when using aliased paths as menu links. Perhaps someone might have a look and see if this is related or gives you some more information/ideas on what happens here.
Comment #13
berdirI'm pretty sure that #2802403: Combination of language negotiation and path aliasing can cause a corrupted route cache, 404s which was just committed fixes this.