Translation issue for terms with disabled language

Created on 25 October 2024, 6 months ago

Problem/Motivation

Copying an English translation of a new piece of content referencing an existing term from a site with English and Welsh to a site with Welsh disabled causes a permanent loop with incomplete content created and the following PHP message:
InvalidArgumentException: Invalid translation language (und) specified. in Drupal\Core\Entity\ContentEntityBase->addTranslation() (line 985 of /var/core/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php).
#0 /var/core/web/modules/contrib/entity_share/modules/entity_share_client/src/Service/ImportService.php(500): Drupal\Core\Entity\ContentEntityBase->addTranslation()
#1 /var/core/web/modules/contrib/entity_share/modules/entity_share_client/src/Service/ImportService.php(279): Drupal\entity_share_client\Service\ImportService->getProcessedEntity()

Steps to reproduce

Source site with English and Welsh and two pieces of English content referencing the same term.
Destination site with English and Welsh (welsh disabled).
Pull one piece of content across - successfully creating the content and the term.
Pull across the second piece of content across - a loop, the above PHP error in the log and an incomplete piece of content.

Proposed resolution

The ImportService class looks for the lang code from $entity_data but in this case lang code is not one of the attributes, which results in storing 'und'. Later the code looks for this translation and because it is not there it tries to create it causing the above error.

A temporary fix is to get it from the $remote_entity in this circumstance. I attach a patch for this.

A better fix is to work out why it is not in the $entity_data attributes.

Remaining tasks

Work on a longer term solution.

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Active

Version

3.0

Component

Entity Share Client

Created by

🇬🇧United Kingdom Rory Downes

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

Comments & Activities

Production build 0.71.5 2024