Alias not using language undefined when alias is not translatable

Created on 21 February 2018, about 7 years ago
Updated 30 November 2023, over 1 year ago

When an entity is set as translatable, but the alias field is not, the alias created still uses the entity language.
This causes that there is no alias for other languages.

Checking if the alias field itself is also translatable, and if not, setting the alias to language undefined might fix this?

🐛 Bug report
Status

Postponed: needs info

Version

1.0

Component

Code

Created by

🇧🇪Belgium StryKaizer Belgium

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇭🇷Croatia Aporie

    Stomped against the same issue.

    In my case, I needed to bulk rebuild URLs on a multilingual website. Problem is, with the snippet above, I could not overwrite translated aliases (from token context, i.e [node:title]) because it would only create aliases for non translated version of the entities (when und is called).

    Tweaking the snippet to pass LanguageInterface::LANGCODE_NOT_SPECIFIED only on default language entities would get me with all aliases overwritten except the default one (i.e "en").

    Ended up making this small patch, which feels more like a hack but does the work. I have now all my aliases from "translated" languages (served by their translated alias version) and not "translated" languages (served by "und") overwritten.

  • 🇭🇷Croatia Aporie

    I think I got a more robust solution.

    Indeed, it takes over core Drupal\path_alias\AliasRepository::lookupBySystemPath to work around #3, and it should probably be aligned with core.

    The overall idea of the patch is to force load the current node language when loading the alias (and not using addLanguageFallback from core lookupBySystemPath to decide whether we should pick "und" or current language) and then to generate an "und" alias when saving the default translation entity.

    I'm attaching it, if that can help, be improved.

  • 🇭🇷Croatia Aporie

    Patch for #8

  • Status changed to Active 6 months ago
  • 🇩🇪Germany geek-merlin Freiburg, Germany

    No additional info needed. Patches can mature parallel.

Production build 0.71.5 2024