incompatible with language-neutral aliases

Created on 26 March 2024, 3 months ago

Problem/Motivation

If you use a language-neutral alias for a node, it confuses \Drupal\soft_translations\SoftTranslationsManager::getSoftTranslations() into thinking that node is translated into every language on the site.

Steps to reproduce

Iā€™m not 100% sure of these repro steps. They should work, but last I checked there were still some core bugs around language-neutral aliases.

1. Set up multilingual site, English as default language, plus German, Spanish, and French.
2. Create node 1 in English with no alias.
3. Create a language-neutral (langcode und) URL alias for the node, at /test-node. The node is now reachable in English via /test-node.
4. Create node 2, in German, with the alias /test-node.
5. The soft translations table at node/2/translations should have one row, representing the English node/1, but it will have three copies of that identical row.

What happens is that SoftTranslationsManager::getSoftTranslations() uses \Drupal\path_alias\AliasManager::getPathByAlias() as a way of determining which languages have content available at /test-node, and the existence of a language-neutral alias means that calling getPathByAlias('/test-node', $langcode) will succeed no matter what langcode gets passed.

Iā€™m filing the issue without a patch because Iā€™m not sure what the right fix is. Using aliases as the detection mechanism seems like the right architectureā€”thatā€™s what determines whether a soft translation exists at allā€”but itā€™s insufficient when there are language-neutral aliases. Maybe it should look up the entire alias, not just the path, and check the langcode field to see whether the alias being returned is language-neutral, and if so, fall back on checking the node itself for available translations in that language? Thatā€™s more heavyweight than using aliases but I canā€™t think of another way to do it correctly.

šŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

šŸ‡ŗšŸ‡øUnited States ksenzee Seattle area

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024