Node menu link translation breaks content translation

Created on 31 August 2020, about 4 years ago
Updated 16 May 2023, over 1 year ago

Problem/Motivation

Enabled content_translation, menu_item_field and token modules.

When i used 'Provide a menu link' at original language, then goto translation, content_translation will broken.

menu_link_content: Drupal\Core\Entity\EntityStorageException: Invalid translation language (und) specified. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 847 of /mnt/www/html/mhicom01live/docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Because content_translation will try to get source language when user want to translate an entity, at core/modules/content_translation/content_translation.module::content_translation_entity_presave()

but in token_node_menu_link_submit(), did not set the source language for menu translation, so content_translation get the source language was 'und', then at Drupal\content_translation\FieldTranslationSynchronizer::synchronizeFields()::177, getTranslation by und will throw error.

Steps to reproduce

- Enable content_translation, menu_item_field and token modules.
- Enable English and Japanese.
- Create a menu type, add field_image file field.
- Create an English node.
- Create a menu item by menu type above, and node reference by the node above, and setup the field_image.
- Goto node translation, add a Japanese node, save will show error.

Proposed resolution

None.

Remaining tasks


- Add test script.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Needs review

Version

1.6

Component

Code

Created by

🇨🇳China Oscaner

Live updates comments and jobs are added and updated live.
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.

Production build 0.71.5 2024