diff --git a/core/modules/config_translation/migrations/d6_user_profile_field_instance_translation.yml b/core/modules/config_translation/migrations/d6_user_profile_field_instance_translation.yml index 9b03aa08bf57774835f4bb4cdd86e41344c7cf2c..0f728f665829e0b9b5ea85083177f594fa3b6d38 100644 --- a/core/modules/config_translation/migrations/d6_user_profile_field_instance_translation.yml +++ b/core/modules/config_translation/migrations/d6_user_profile_field_instance_translation.yml @@ -12,7 +12,18 @@ process: langcode: language entity_type: 'constants/entity_type' bundle: 'constants/bundle' - field_name: name + field_name: + - + plugin: migration_lookup + migration: user_profile_field + source: fid + - + plugin: skip_on_empty + method: row + - + plugin: extract + index: + - 1 property: plugin: static_map source: property diff --git a/core/modules/config_translation/tests/src/Kernel/Migrate/d6/MigrateUserProfileFieldInstanceTranslationTest.php b/core/modules/config_translation/tests/src/Kernel/Migrate/d6/MigrateUserProfileFieldInstanceTranslationTest.php index 01d5ec929d8aa8b5b2d0dc45afd43fc5ae9422fe..c941e41282a617c035f2a486884c5bb7b42d823c 100644 --- a/core/modules/config_translation/tests/src/Kernel/Migrate/d6/MigrateUserProfileFieldInstanceTranslationTest.php +++ b/core/modules/config_translation/tests/src/Kernel/Migrate/d6/MigrateUserProfileFieldInstanceTranslationTest.php @@ -28,7 +28,7 @@ public function testUserProfileFields() { ]); $language_manager = $this->container->get('language_manager'); - $config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.field.user.user.profile_love_migrations'); + $config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.field.user.user.profile_really_really_love_mig'); $this->assertSame("J'aime les migrations", $config_translation->get('label')); $this->assertSame("Si vous cochez cette case, vous aimez les migrations.", $config_translation->get('description')); diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal6.php b/core/modules/migrate_drupal/tests/fixtures/drupal6.php index 7b0eba3e03644e2ac6f75194e526768e793c4ce5..502e2631d5b80ce99259613395ac14703f0ee58a 100644 --- a/core/modules/migrate_drupal/tests/fixtures/drupal6.php +++ b/core/modules/migrate_drupal/tests/fixtures/drupal6.php @@ -8802,7 +8802,7 @@ )) ->values(array( 'lid' => '509', - 'objectid' => 'profile_sell_address', + 'objectid' => 'profile_sell_Address', 'type' => 'field', 'property' => 'title', 'objectindex' => '0', @@ -8810,7 +8810,7 @@ )) ->values(array( 'lid' => '510', - 'objectid' => 'profile_sell_address', + 'objectid' => 'profile_sell_Address', 'type' => 'field', 'property' => 'explanation', 'objectindex' => '0', @@ -8890,7 +8890,7 @@ )) ->values(array( 'lid' => '520', - 'objectid' => 'profile_love_migrations', + 'objectid' => 'profile_really_really_love_migrations', 'type' => 'field', 'property' => 'title', 'objectindex' => '0', @@ -8898,7 +8898,7 @@ )) ->values(array( 'lid' => '521', - 'objectid' => 'profile_love_migrations', + 'objectid' => 'profile_really_really_love_migrations', 'type' => 'field', 'property' => 'explanation', 'objectindex' => '0', @@ -9848,6 +9848,14 @@ 'objectindex' => '138', 'format' => '0', )) +->values(array( + 'lid' => '1678', + 'objectid' => 'profile_really_really_love_migrating', + 'type' => 'field', + 'property' => 'title', + 'objectindex' => '0', + 'format' => '0', +)) ->execute(); $connection->schema()->createTable('i18n_variable', array( @@ -14168,14 +14176,14 @@ )) ->values(array( 'lid' => '509', - 'location' => 'field:profile_sell_address:title', + 'location' => 'field:profile_sell_Address:title', 'textgroup' => 'profile', 'source' => 'Sell your email address?', 'version' => '1', )) ->values(array( 'lid' => '510', - 'location' => 'field:profile_sell_address:explanation', + 'location' => 'field:profile_sell_Address:explanation', 'textgroup' => 'profile', 'source' => "If you check this box, we'll sell your address to spammers to help line the pockets of our shareholders. Thanks!", 'version' => '1', @@ -14245,14 +14253,14 @@ )) ->values(array( 'lid' => '520', - 'location' => 'field:profile_love_migrations:title', + 'location' => 'field:profile_really_really_love_migrations:title', 'textgroup' => 'profile', - 'source' => 'I love migrations', + 'source' => 'I really, really, really love migrations', 'version' => '1', )) ->values(array( 'lid' => '521', - 'location' => 'field:profile_love_migrations:explanation', + 'location' => 'field:profile_really_really_love_migrations:explanation', 'textgroup' => 'profile', 'source' => 'If you check this box, you love migrations.', 'version' => '1', @@ -22342,6 +22350,13 @@ 'source' => 'Test menu link 1', 'version' => '1', )) +->values(array( + 'lid' => '1678', + 'location' => 'field:profile_really_really_love_migrating:title', + 'textgroup' => 'profile', + 'source' => 'I really, really, really love migrating', + 'version' => '1', +)) ->execute(); $connection->schema()->createTable('locales_target', array( @@ -26520,7 +26535,7 @@ 'language' => 'fr', 'plid' => '0', 'plural' => '0', - 'i18n_status' => '0', + 'i18n_status' => '1', )) ->values(array( 'lid' => '521', @@ -27386,6 +27401,14 @@ 'plural' => '0', 'i18n_status' => '0', )) +->values(array( + 'lid' => '1678', + 'translation' => 'fr - I really, really, really love migrating ', + 'language' => 'fr', + 'plid' => '0', + 'plural' => '0', + 'i18n_status' => '0', +)) ->values(array( 'lid' => '66', 'translation' => 'zu - CCK - Aucune Intégration aux Vues', @@ -44837,7 +44860,7 @@ ->values(array( 'fid' => '10', 'title' => 'Sell your email address?', - 'name' => 'profile_sell_address', + 'name' => 'profile_sell_Address', 'explanation' => "If you check this box, we'll sell your address to spammers to help line the pockets of our shareholders. Thanks!", 'category' => 'Communication preferences', 'page' => 'People who want us to sell their address', @@ -44911,8 +44934,8 @@ )) ->values(array( 'fid' => '15', - 'title' => 'I love migrations', - 'name' => 'profile_love_migrations', + 'title' => 'I really, really, really love migrations', + 'name' => 'profile_really_really_love_migrations', 'explanation' => 'If you check this box, you love migrations.', 'category' => 'Personal information', 'page' => 'People who love migrations', @@ -44924,6 +44947,21 @@ 'autocomplete' => '0', 'options' => '', )) +->values(array( + 'fid' => '16', + 'title' => 'I really, really, really love migrating', + 'name' => 'profile_really_really_love_migrating', + 'explanation' => '', + 'category' => 'Personal information', + 'page' => '', + 'type' => 'checkbox', + 'weight' => '0', + 'required' => '0', + 'register' => '0', + 'visibility' => '2', + 'autocomplete' => '0', + 'options' => '', +)) ->execute(); $connection->schema()->createTable('profile_values', array( @@ -45136,6 +45174,11 @@ 'uid' => '17', 'value' => 'a:3:{s:5:"month";s:2:"12";s:3:"day";s:2:"18";s:4:"year";s:4:"1942";}', )) +->values(array( + 'fid' => '15', + 'uid' => '2', + 'value' => '1', +)) ->execute(); $connection->schema()->createTable('role', array( diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php index 2468cd47448de11f2e7ec72fc645e78d3b5c806b..abd6b8993caec1da96ef46d4eec024d17536ce39 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php @@ -64,8 +64,8 @@ protected function getEntityCounts() { 'contact_form' => 5, 'configurable_language' => 5, 'editor' => 2, - 'field_config' => 88, - 'field_storage_config' => 62, + 'field_config' => 89, + 'field_storage_config' => 63, 'file' => 8, 'filter_format' => 7, 'image_style' => 5, diff --git a/core/modules/user/migrations/user_profile_entity_display.yml b/core/modules/user/migrations/user_profile_entity_display.yml index 73366362690a4b14bf9ca64afb150100b13cde3f..eafba00475a5248dbdb218bd16bb1a414ca32861 100644 --- a/core/modules/user/migrations/user_profile_entity_display.yml +++ b/core/modules/user/migrations/user_profile_entity_display.yml @@ -17,7 +17,18 @@ process: entity_type: 'constants/entity_type' bundle: 'constants/bundle' view_mode: 'constants/view_mode' - field_name: name + field_name: + - + plugin: migration_lookup + migration: user_profile_field + source: fid + - + plugin: skip_on_empty + method: row + - + plugin: extract + index: + - 1 type: plugin: static_map source: type diff --git a/core/modules/user/migrations/user_profile_entity_form_display.yml b/core/modules/user/migrations/user_profile_entity_form_display.yml index 44a5c5333df2b8d8f1b5db9caaaae00f45c215ff..7416ac87a6a0c6963dd330e2d0451a1362243e5c 100644 --- a/core/modules/user/migrations/user_profile_entity_form_display.yml +++ b/core/modules/user/migrations/user_profile_entity_form_display.yml @@ -14,7 +14,18 @@ source: process: entity_type: 'constants/entity_type' bundle: 'constants/bundle' - field_name: name + field_name: + - + plugin: migration_lookup + migration: user_profile_field + source: fid + - + plugin: skip_on_empty + method: row + - + plugin: extract + index: + - 1 form_mode: 'constants/form_mode' type: plugin: static_map diff --git a/core/modules/user/migrations/user_profile_field.yml b/core/modules/user/migrations/user_profile_field.yml index 94d7defd06c2570fb0572eca5f8d6f4153476fb7..af6018efcce3d7f47e1d759542969e0a9f8adb55 100644 --- a/core/modules/user/migrations/user_profile_field.yml +++ b/core/modules/user/migrations/user_profile_field.yml @@ -10,7 +10,15 @@ source: entity_type: user process: entity_type: 'constants/entity_type' - field_name: name + field_name: + - + plugin: machine_name + source: name + - + plugin: make_unique_entity_field + length: 30 + entity_type: field_storage_config + field: field_name type: plugin: static_map source: type diff --git a/core/modules/user/migrations/user_profile_field_instance.yml b/core/modules/user/migrations/user_profile_field_instance.yml index 50e0bd2839705d846817ea494051e174bbdefdcd..b6c706ceb703d5096a2dec400d0ab578ebe82f64 100644 --- a/core/modules/user/migrations/user_profile_field_instance.yml +++ b/core/modules/user/migrations/user_profile_field_instance.yml @@ -14,7 +14,18 @@ process: bundle: 'constants/bundle' label: title description: explanation - field_name: name + field_name: + - + plugin: migration_lookup + migration: user_profile_field + source: fid + - + plugin: skip_on_empty + method: row + - + plugin: extract + index: + - 1 required: required destination: plugin: entity:field_config diff --git a/core/modules/user/src/Plugin/migrate/ProfileValues.php b/core/modules/user/src/Plugin/migrate/ProfileValues.php index b082d591af24a91d464b240267764cc1f195e913..8399436c033c1c91c29cc45093a2632bd479cbc6 100644 --- a/core/modules/user/src/Plugin/migrate/ProfileValues.php +++ b/core/modules/user/src/Plugin/migrate/ProfileValues.php @@ -3,6 +3,8 @@ namespace Drupal\user\Plugin\migrate; use Drupal\migrate\Exception\RequirementsException; +use Drupal\migrate\MigrateExecutable; +use Drupal\migrate\MigrateSkipRowException; use Drupal\migrate\Plugin\Migration; /** @@ -31,11 +33,28 @@ public function getProcess() { $definition['idMap']['plugin'] = 'null'; try { $profile_field_migration = $this->migrationPluginManager->createStubMigration($definition); + $migrate_executable = new MigrateExecutable($profile_field_migration); $source_plugin = $profile_field_migration->getSourcePlugin(); $source_plugin->checkRequirements(); foreach ($source_plugin as $row) { $name = $row->getSourceProperty('name'); - $this->process[$name] = $name; + $fid = $row->getSourceProperty('fid'); + // The user profile field name can be greater than 32 characters. Use + // the migrated profile field name in the process pipeline. + $configuration = + [ + 'migration' => 'user_profile_field', + 'source_ids' => $fid, + ]; + $plugin = $this->processPluginManager->createInstance('migration_lookup', $configuration, $profile_field_migration); + $new_value = $plugin->transform($fid, $migrate_executable, $row, 'tmp'); + if (isset($new_value[1])) { + // Set the destination to the migrated profile field name. + $this->process[$new_value[1]] = $name; + } + else { + throw new MigrateSkipRowException("Can't migrate source field $name."); + } } } catch (RequirementsException $e) { diff --git a/core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileEntityDisplayTest.php b/core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileEntityDisplayTest.php index a4a203685f1432c0f5803c4dba800a625c03f21e..ac7c181b5ff0d78ebd85dc2ed22af1e2a1c46015 100644 --- a/core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileEntityDisplayTest.php +++ b/core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileEntityDisplayTest.php @@ -47,6 +47,10 @@ public function testUserProfileFields() { // Test PROFILE_HIDDEN field is hidden. $this->assertNull($display->getComponent('profile_sold_to')); + + // Test a checkbox field. + $component = $display->getComponent('profile_really_really_love_mig'); + $this->assertIdentical('list_default', $component['type']); } } diff --git a/core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileEntityFormDisplayTest.php b/core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileEntityFormDisplayTest.php index a2b01aa1712eb327fa0030b717e352bdc620fdf7..2fcec8dabb770b9e500bbaeea75af781061f2db1 100644 --- a/core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileEntityFormDisplayTest.php +++ b/core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileEntityFormDisplayTest.php @@ -49,7 +49,7 @@ public function testUserProfileEntityFormDisplay() { $this->assertNull($display->getComponent('profile_sold_to')); // Test that a checkbox field has the proper display label setting. - $component = $display->getComponent('profile_love_migrations'); + $component = $display->getComponent('profile_really_really_love_mig'); $this->assertIdentical('boolean_checkbox', $component['type']); $this->assertIdentical(TRUE, $component['settings']['display_label']); } diff --git a/core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileFieldInstanceTest.php b/core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileFieldInstanceTest.php index 97133325875d4196f4feef62b1bb470a64fc36fa..ecc9bc9651f1d2252e0d2fb0f295bf4a4513cd3f 100644 --- a/core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileFieldInstanceTest.php +++ b/core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileFieldInstanceTest.php @@ -68,8 +68,8 @@ public function testUserProfileFields() { $this->assertIdentical("Enter your birth date and we'll send you a coupon.", $field->getDescription()); // Another migrated checkbox field, with a different source visibility setting. - $field = FieldConfig::load('user.user.profile_love_migrations'); - $this->assertIdentical('I love migrations', $field->label()); + $field = FieldConfig::load('user.user.profile_really_really_love_mig'); + $this->assertIdentical('I really, really, really love migrations', $field->label()); $this->assertIdentical("If you check this box, you love migrations.", $field->getDescription()); } diff --git a/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserProfileValuesTest.php b/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserProfileValuesTest.php index e734517a5ee2fa8397fd5689fd3dd62ac8106cf4..71acad69f2f36ed48b83bc24c83468ba4b94c4ec 100644 --- a/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserProfileValuesTest.php +++ b/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserProfileValuesTest.php @@ -59,7 +59,13 @@ public function testUserProfileValues() { $this->assertNull($user->profile_blog->title); $this->assertIdentical([], $user->profile_blog->options); $this->assertIdentical('http://example.com/blog', $user->profile_blog->uri); - $this->assertNull($user->profile_love_migrations->value); + + // Check that the source profile field names that are longer than 32 + // characters have been migrated. + $this->assertNotNull($user->getFieldDefinition('profile_really_really_love_mig')); + $this->assertNotNull($user->getFieldDefinition('profile_really_really_love_mig1')); + $this->assertSame('1', $user->profile_really_really_love_mig->value); + $this->assertNull($user->profile_really_really_love_mig1->value); $user = User::load(8); $this->assertIdentical('Forward/slash', $user->profile_sold_to->value);