diff --git docroot/modules/contrib/tmgmt/sources/content/src/Plugin/tmgmt/Source/ContentEntitySource.php docroot/modules/contrib/tmgmt/sources/content/src/Plugin/tmgmt/Source/ContentEntitySource.php index 45d8763612..f8624f45c2 100644 --- docroot/modules/contrib/tmgmt/sources/content/src/Plugin/tmgmt/Source/ContentEntitySource.php +++ docroot/modules/contrib/tmgmt/sources/content/src/Plugin/tmgmt/Source/ContentEntitySource.php @@ -225,7 +225,7 @@ public function getData(JobItemInterface $job_item) { * @return array $data * Translatable data. */ - public function extractTranslatableData(ContentEntityInterface $entity) { + public function extractTranslatableData(ContentEntityInterface $entity, &$entityRegistry = []) { $field_definitions = $entity->getFieldDefinitions(); $exclude_field_types = ['language']; $exclude_field_names = ['moderation_state']; @@ -301,7 +301,13 @@ public function extractTranslatableData(ContentEntityInterface $entity) { if ($content_translation_manager->isEnabled($referenced_entity->getEntityTypeId(), $referenced_entity->bundle()) && $referenced_entity->hasTranslation($langcode)) { $referenced_entity = $referenced_entity->getTranslation($langcode); } - $data[$field_name][$delta][$property_key] = $this->extractTranslatableData($referenced_entity); + + // Prevent recursion. + $ref_code = $referenced_entity->getEntityType()->getLabel() . ':' . $referenced_entity->id(); + if (!isset($entityRegistry[$ref_code])) { + $entityRegistry[$ref_code] = 1; + $data[$field_name][$delta][$property_key] = $this->extractTranslatableData($referenced_entity, $entityRegistry); + } // Use the ID of the entity to identify it later, do not rely on the // UUID as content entities are not required to have one. $data[$field_name][$delta][$property_key]['#id'] = $property->getValue()->id();