redirect.repository service does not use a proper language fallback mechanism

Created on 30 January 2020, almost 5 years ago
Updated 12 December 2024, 9 days ago

Following is the current language fallback logic used in the path.alias_repository service:

    $hashes = [Redirect::generateHash($source_path, $query, $language)];
    if ($language != Language::LANGCODE_NOT_SPECIFIED) {
      $hashes[] = Redirect::generateHash($source_path, $query, Language::LANGCODE_NOT_SPECIFIED);
    }

This logic doesn't take into account where custom/contrib modules may implement hook_language_fallback_candidates_alter() to add/remove fallback candidate languages.

Example of one such contrib module:
Language hierarchy: https://www.drupal.org/project/language_hierarchy

Attaching a patch to user proper fallback mechanism, with added query tag to allow contrib modules to use this functionality.

🐛 Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

🇮🇳India dipakmdhrm

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • needs profiling

    It may affect performance, and thus requires in-depth technical reviews and profiling.

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.

  • 🇨🇦Canada alberto56

    Hi all, the patch at #16 does not apply anymore; I have updated it so that it now applies.

  • 🇬🇧United Kingdom james.williams

    @alberto56 that looks like a reroll of the patch from comment 13? But the patch in comment 14 has the latest work, so that's the one that should be re-rolled, if even still necessary.

  • 🇨🇦Canada alberto56

    Thanks @james.willams for the extra info! In fact my team was using the patch which is named "3110113--16--language-fallback.patch". Because there is a "16" in the name of the patch I assumed it was from comment 16. My apologies if it is not. (You can see it by clicking "Show 9 more files" under the patch 14 at the top of this issue.) The reason I re-rolled that one is because it has long been used by my team with previous versions of this module, without any obvious adverse effects. If anyone is in the same situation they can find my "19" patch by clicking "Show 9 more files" at the top of this issue.

    Cheers.

Production build 0.71.5 2024