Path alias language doesn't changes on changing of node language

Created on 16 July 2025, 11 days ago

Problem/Motivation

when you create a node with a language, the path alias is saved with a language code. If you later change the node's language, the path alias's language code isn't updated to match the new language. This can cause the path alias not to show up when editing the node.

Steps to reproduce

  1. Create a node with a language. Let's assume the language is Japanese.
  2. Set a path alias if it is not auto-generated.
  3. Save the node.
  4. Now edit the same node and change only the language (let's assume the new language is French (FR)) of the node and save it.
  5. Now open the node in the edit form. You will see the path alias will be empty.

Proposed resolution

This issue occurs because the path alias's language doesn't update when the node's language is changed. You'll see an entry in the path_alias table with the old language code. To fix this, you need to update the path alias if the parent node's language and the path alias's language don't match.

🐛 Bug report
Status

Active

Version

10.4

Component

path.module

Created by

🇮🇳India vikramsaini1609

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

Merge Requests

Comments & Activities

  • Issue created by @vikramsaini1609
  • Pipeline finished with Failed
    11 days ago
    Total: 660s
    #548807
  • 🇮🇳India saiprasad_g

    This patch resolves an issue where changing the language of an existing node causes the previously assigned path alias to disappear from the edit form. The root cause is that the alias remains tied to the original language code in the path_alias table, and Drupal does not automatically update it when the node’s language is changed. This results in a mismatch, making the alias effectively invisible or unusable for the new language. The patch adds logic in the Node::preSave() method to detect when the node's language has changed. If a change is detected, it generates a new alias with the updated language code and assigns it to the node's path field. Additionally, it stores the old and new languages to display a helpful message to the user after saving, indicating the alias has been updated. This ensures that the alias language remains synchronized with the node language, preventing confusion or routing issues in multilingual environments

  • The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • First commit to issue fork.
  • Pipeline finished with Failed
    2 days ago
    #556656
Production build 0.71.5 2024