Problem/Motivation

Getting the below HTTP 500 fatal error on trying to add a translation of an 'draft' English node, Which was earlier 'published' with language 'not defined'.
InvalidArgumentException: Invalid translation language (und) specified. in Drupal\Core\Entity\ContentEntityBase->addTranslation() (line 955 of /core/lib/Drupal/Core/Entity/ContentEntityBase.php).

Steps to reproduce

  • Install Vanilla Drupal's Standard Installation Profile with English as site language.(Note: I faced this error on 8.x and 9.x. So Install any version you want.)
  • Log in as an admin and enable the following modules
  1. Configuration Translation
  2. Content Translation
  3. Interface Translation
  4. Language
  5. Content Moderation
  6. Workflows
  • Go to the path /admin/config/regional/language/add & add the French language to your site.
  • Configure URL language detection method by visiting the path /admin/config/regional/language/detection/url such that it has below values:
    1. Part of the URL that determines language: Path Prefix should be selected
    2. Path Prefix Configuration: en in English textfield, And fr in French textfield.
  • Create content type, Allow content of this content type to be translatable. And show the 'Language' dropdown on this content's add/edit page.
  • Make this content type follow the default editorial workflow by visiting the path /admin/config/workflow/workflows/manage/editorial
  • Create a node of this content type, Such that it's published with language as Not Specified.
  • Now, Edit the newly created node, Change its language to English and save it as a draft.
  • On the node view page, You will see the Translate tab. Click on it.
  • Try adding the french translation of this node. And you will see the fatal error shown in attached screenshot.
  • Note: When the content type does not follow the 'editorial' workflow, Then you won't see the fatal error

    Proposed resolution

    1. Ideally, We should not allow language switching of an existing node.
    2. But in the real world content editors tend to do language switching. Hence If we are allowing language switching, Then we should not get an fatal error for adding translations.

    Remaining tasks

    "None at the time of creating this issue."

    User interface changes

    "None at the time of creating this issue."

    API changes

    "None at the time of creating this issue."

    Data model changes

    "None at the time of creating this issue."

    Release notes snippet

    "None at the time of creating this issue."

    CommentFileSizeAuthor
    HTTP 500 InvalidArgumentException.png497.06 KBkunalkursija

    Comments

    kunalkursija created an issue. See original summary.

    kunalkursija’s picture

    Version: 8.9.x-dev » 9.2.x-dev

    Changing version to 9.2.x.
    Note: This error exists on both 8.x & 9.x

    sam152’s picture

    Issue tags: +content moderation multilingual bug

    Version: 9.2.x-dev » 9.3.x-dev

    Drupal 9.1.10 (June 4, 2021) and Drupal 9.2.10 (November 24, 2021) were the last bugfix releases of those minor version series. Drupal 9 bug reports should be targeted for the 9.3.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

    Version: 9.3.x-dev » 9.4.x-dev

    Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

    Version: 9.4.x-dev » 9.5.x-dev

    Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

    Version: 9.5.x-dev » 11.x-dev

    Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

    Version: 11.x-dev » main

    Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

    Read more in the announcement.