- Issue created by @missvengerberg
- 🇪🇸Spain missvengerberg
Wrong file in my previous message, apologies.
Fix the bug of no reseting the language manager.
Hi! We are running a Drupal 9 multilanguage with module Content Language Access enabled to prevent users to view content different from the current's language site.
We've used XMLSitemap to create a Sitemap per language/domain:
domain.com/sitemap.xml
es.domain.com/sitemap.xml
it.domain.com/sitemap.xml
fr.domain.com/sitemap.xml
...
The problem presents while generating the content through all the sitemaps. At some point in class, XmlSitemapLinkStorage
there's an well & expected check access for the annonymous user: $entity->access('view', $annonymous)
so, the content different from the current's language site is denied, so the link is discarded from the sitemap.
The result is you have domain.com/sitemap.xml
with the content and the others domains get their sitemaps empty, with just their headers.
Since we can't bypass the content language access permission for annonymous (it's not an option for us) we thought of switching the current language during the process. We implemented a language negotiator to do so, based on this answer. https://drupal.stackexchange.com/a/216051
I've made a patch what works just fine for us, maybe someone finds this useful. All suggestions are very welcome too!
Needs work
1.4
Code
Wrong file in my previous message, apologies.
Fix the bug of no reseting the language manager.