diff --git a/core/modules/user/src/Plugin/migrate/source/d7/User.php b/core/modules/user/src/Plugin/migrate/source/d7/User.php index 286857a6b6b8a78c77f5ef8fa11c31ecc77488d5..affcf58b2076d40fd8d2c4b477ed9418c0013453 100644 --- a/core/modules/user/src/Plugin/migrate/source/d7/User.php +++ b/core/modules/user/src/Plugin/migrate/source/d7/User.php @@ -76,7 +76,7 @@ public function prepareRow(Row $row) { ->fetchCol(); $row->setSourceProperty('roles', $roles); - $row->setSourceProperty('data', unserialize($row->getSourceProperty('data'))); + $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. diff --git a/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d7/UserTest.php b/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d7/UserTest.php index 5015303c3f0bb8d794a89c779040d2cae2603304..5f8a90a6552747302dee3e0786ff79d38ecbd5c6 100644 --- a/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d7/UserTest.php +++ b/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d7/UserTest.php @@ -54,6 +54,18 @@ public function providerSource() { 'field_file_display' => 1, 'field_file_description' => 'None', ], + [ + 'entity_type' => 'user', + 'bundle' => 'user', + 'deleted' => 0, + 'entity_id' => 3, + 'revision_id' => NULL, + 'language' => 'und', + 'delta' => 0, + 'field_file_fid' => 42, + 'field_file_display' => 1, + 'field_file_description' => 'None', + ], ]; $tests[0]['source_data']['role'] = [ [ @@ -81,12 +93,34 @@ public function providerSource() { 'init' => 'odo@local.host', 'data' => 'a:1:{s:7:"contact";i:1;}', ], + [ + 'uid' => '3', + 'name' => 'foo', + 'pass' => 'password', + 'mail' => 'foo@local.host', + 'theme' => '', + 'signature' => '', + 'signature_format' => 'filtered_html', + 'created' => '1647752102', + 'access' => '0', + 'login' => '0', + 'status' => '1', + 'timezone' => 'America/Chicago', + 'language' => '', + 'picture' => '0', + 'init' => 'foo@local.host', + 'data' => NULL, + ], ]; $tests[0]['source_data']['users_roles'] = [ [ 'uid' => 2, 'rid' => 2, ], + [ + 'uid' => 3, + 'rid' => 2, + ], ]; // The expected results. @@ -118,6 +152,31 @@ public function providerSource() { ], ], ], + [ + 'uid' => '3', + 'name' => 'foo', + 'pass' => 'password', + 'mail' => 'foo@local.host', + 'signature' => '', + 'signature_format' => 'filtered_html', + 'created' => '1647752102', + 'access' => '0', + 'login' => '0', + 'status' => '1', + 'timezone' => 'America/Chicago', + 'language' => '', + 'picture' => '0', + 'init' => 'foo@local.host', + 'roles' => [2], + 'data' => FALSE, + 'field_file' => [ + [ + 'fid' => 42, + 'display' => 1, + 'description' => 'None', + ], + ], + ], ]; return $tests;