Prevent redundant alias update caused by path alias language fallback.

Created on 13 February 2020, almost 5 years ago
Updated 29 August 2024, 3 months ago

Prerequisite:

Drupal 8.8.0 or higher.
Install English, French & German languages.
Install pathauto.
In pathauto settings, set "Update action" to "Create a new alias. Delete the old alias.".

Steps:

Create an English node with no alias. Let's say this node is node/1
Create French translation of node/1 with no alias
Manually add an alias '/test-node' to point at 'node/1' for all languages. i.e. the alias is created in 'und'
Create German translation of node/1 with new alias 'german-test-node'

Expectation:

No changes to und aias. i.e. '/test-node' should still be an alias to 'node.1' for und.
New german aias is created. i.e. 'german-test-node' becomes and alis for de language

Actual result:

und alias is updated to 'german-test-node'. Original one is deleted.
No new german aias is created.

Feature request
Status

Closed: outdated

Version

1.6

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.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

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

  • achap 🇦🇺

    I had a look at the linked issues and tried some patches but they didn't stop this issue occurring. I also downloaded the latest version of this module and and it's still occurring. Where was this fixed? (Using core 10.2)

  • Status changed to Needs review 3 months ago
  • achap 🇦🇺

    Seeing as this is still occurring I re-opened and opened a MR. Added code in the AliasStorageHelper class rather than PathautoGenerator

  • Pipeline finished with Success
    3 months ago
    Total: 173s
    #267717
  • Status changed to Needs work 7 days ago
  • achap 🇦🇺

    Hmmm both my MR and patch #10 will result in duplicate aliases being created every time you save a node if you do something like this in hook_pathauto_alias_alter

    if ($context['language'] === \Drupal::languageManager()
          ->getDefaultLanguage()
          ->getId()) {
          $context['language'] = LanguageInterface::LANGCODE_NOT_SPECIFIED;
        }
    
  • Pipeline finished with Success
    7 days ago
    Total: 169s
    #351617
  • achap 🇦🇺

    Updated my fork to handle duplicate aliases caused by altering path alias languages.

    Also, I feel like this is actually a bug report, because it's impossible to create a new alias in a different language without overriding the fallback alias. The title could probably be updated too but I'll leave that alone for now.

Production build 0.71.5 2024