diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d8/ContentEntity.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d8/ContentEntity.php index ec7d95b31c..b623acff19 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/d8/ContentEntity.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d8/ContentEntity.php @@ -119,15 +119,15 @@ protected function getFields($entity_type, $bundle = NULL) { * The entity ID. * @param int|null $revision_id * (optional) The entity revision ID. + * @param string|null $langcode + * (optional) The entity langcode. * * @throws \Drupal\migrate\MigrateException * * @return array * The raw field values, keyed by delta. - * - * @todo Support multilingual field values. */ - protected function getFieldValues($entity_type, $field_name, $entity_id, $revision_id = NULL) { + protected function getFieldValues($entity_type, $field_name, $entity_id, $revision_id = NULL, $langcode = NULL) { $table = $this->getDedicatedDataTableName($entity_type, $field_name); $query = $this->select($table, 't') @@ -138,6 +138,9 @@ protected function getFieldValues($entity_type, $field_name, $entity_id, $revisi if ($revision_id) { $query->condition('revision_id', $revision_id); } + if ($langcode) { + $query->condition('langcode', $langcode); + } $values = []; foreach ($query->execute() as $row) { @@ -211,8 +214,8 @@ public function query() { if ($dataTable) { $query = $this->select($dataTable, 'd') ->fields('d'); - $alias = $query->innerJoin($baseTable, 'b', "b.{$idKey} = d.{$idKey}"); - $query->fields($alias); + $alias = $query->leftJoin($baseTable, 'b', "b.{$idKey} = d.{$idKey}"); + $query->fields($alias, [$idKey]); if (!empty($this->configuration['bundle'])) { $query->condition("d.{$bundleKey}", $this->configuration['bundle']); } @@ -260,7 +263,11 @@ public function prepareRow(Row $row) { $revisionKey = $entityDefinition->getKey('revision'); $revisionId = $row->getSourceProperty($revisionKey); } - $row->setSourceProperty($field, $this->getFieldValues($entityType, $field, $entityId, $revisionId)); + $langcode = NULL; + if ($entityDefinition->isTranslatable()) { + $langcode = $row->getSourceProperty('langcode'); + } + $row->setSourceProperty($field, $this->getFieldValues($entityType, $field, $entityId, $revisionId, $langcode)); } return parent::prepareRow($row);