Commit 3d9ba61e authored by webchick's avatar webchick

Issue #2562081 by phenaproxima: d7_user source plugin handles user roles incorrectly

parent 3e3a2074
......@@ -66,11 +66,12 @@ public function fields() {
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
$roles = $this->select('role', 'r')
->fields('r', ['rid', 'name']);
$roles->join('users_roles', 'ur', 'ur.rid = r.rid');
$roles->condition('ur.uid', $row->getSourceProperty('uid'));
$row->setSourceProperty('roles', $roles->execute()->fetchAllKeyed());
$roles = $this->select('users_roles', 'ur')
->fields('ur', ['rid'])
->condition('ur.uid', $row->getSourceProperty('uid'))
->execute()
->fetchCol();
$row->setSourceProperty('roles', $roles);
$row->setSourceProperty('data', unserialize($row->getSourceProperty('data')));
......
......@@ -41,9 +41,7 @@ class UserTest extends MigrateSqlSourceTestCase {
'language' => '',
'picture' => '0',
'init' => 'odo@local.host',
'roles' => [
2 => 'authenticated user',
],
'roles' => [2],
'data' => [
'contact' => 1,
],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment