X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fnode%2Fsrc%2FPlugin%2Fmigrate%2Fsource%2Fd7%2FNode.php;fp=web%2Fcore%2Fmodules%2Fnode%2Fsrc%2FPlugin%2Fmigrate%2Fsource%2Fd7%2FNode.php;h=931a2b94311c02f892cac258c7e9a8504b9d5966;hp=1a9037e7a00a4f0b6772815117cd6ad0bb96a800;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/node/src/Plugin/migrate/source/d7/Node.php b/web/core/modules/node/src/Plugin/migrate/source/d7/Node.php index 1a9037e7a..931a2b943 100644 --- a/web/core/modules/node/src/Plugin/migrate/source/d7/Node.php +++ b/web/core/modules/node/src/Plugin/migrate/source/d7/Node.php @@ -104,17 +104,40 @@ class Node extends FieldableEntity { * {@inheritdoc} */ public function prepareRow(Row $row) { + $nid = $row->getSourceProperty('nid'); + $vid = $row->getSourceProperty('vid'); + $type = $row->getSourceProperty('type'); + + // If this entity was translated using Entity Translation, we need to get + // its source language to get the field values in the right language. + // The translations will be migrated by the d7_node_entity_translation + // migration. + $entity_translatable = $this->isEntityTranslatable('node') && (int) $this->variableGet('language_content_type_' . $type, 0) === 4; + $source_language = $this->getEntityTranslationSourceLanguage('node', $nid); + $language = $entity_translatable && $source_language ? $source_language : $row->getSourceProperty('language'); + // Get Field API field values. - foreach (array_keys($this->getFields('node', $row->getSourceProperty('type'))) as $field) { - $nid = $row->getSourceProperty('nid'); - $vid = $row->getSourceProperty('vid'); - $row->setSourceProperty($field, $this->getFieldValues('node', $field, $nid, $vid)); + foreach ($this->getFields('node', $type) as $field_name => $field) { + // Ensure we're using the right language if the entity and the field are + // translatable. + $field_language = $entity_translatable && $field['translatable'] ? $language : NULL; + $row->setSourceProperty($field_name, $this->getFieldValues('node', $field_name, $nid, $vid, $field_language)); } // Make sure we always have a translation set. if ($row->getSourceProperty('tnid') == 0) { $row->setSourceProperty('tnid', $row->getSourceProperty('nid')); } + + // If the node title was replaced by a real field using the Drupal 7 Title + // module, use the field value instead of the node title. + if ($this->moduleExists('title')) { + $title_field = $row->getSourceProperty('title_field'); + if (isset($title_field[0]['value'])) { + $row->setSourceProperty('title', $title_field[0]['value']); + } + } + return parent::prepareRow($row); }