X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fuser%2Fsrc%2FPlugin%2Fmigrate%2Fsource%2Fd7%2FUser.php;fp=web%2Fcore%2Fmodules%2Fuser%2Fsrc%2FPlugin%2Fmigrate%2Fsource%2Fd7%2FUser.php;h=3400bf55074d35e83c41ab89f742c6e02b090c82;hp=41f9ab4d6ea17671c36d91af7df6e32050c3a475;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/user/src/Plugin/migrate/source/d7/User.php b/web/core/modules/user/src/Plugin/migrate/source/d7/User.php index 41f9ab4d6..3400bf550 100644 --- a/web/core/modules/user/src/Plugin/migrate/source/d7/User.php +++ b/web/core/modules/user/src/Plugin/migrate/source/d7/User.php @@ -62,18 +62,32 @@ class User extends FieldableEntity { * {@inheritdoc} */ public function prepareRow(Row $row) { + $uid = $row->getSourceProperty('uid'); + $roles = $this->select('users_roles', 'ur') ->fields('ur', ['rid']) - ->condition('ur.uid', $row->getSourceProperty('uid')) + ->condition('ur.uid', $uid) ->execute() ->fetchCol(); $row->setSourceProperty('roles', $roles); $row->setSourceProperty('data', unserialize($row->getSourceProperty('data'))); + // 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_user_entity_translation + // migration. + $entity_translatable = $this->isEntityTranslatable('user'); + $source_language = $this->getEntityTranslationSourceLanguage('user', $uid); + $language = $entity_translatable && $source_language ? $source_language : $row->getSourceProperty('language'); + $row->setSourceProperty('entity_language', $language); + // Get Field API field values. - foreach (array_keys($this->getFields('user')) as $field) { - $row->setSourceProperty($field, $this->getFieldValues('user', $field, $row->getSourceProperty('uid'))); + foreach ($this->getFields('user') 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('user', $field_name, $uid, NULL, $field_language)); } // Get profile field values. This code is lifted directly from the D6