summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2018-05-17 12:12:27 (GMT)
committerNathaniel Catchpole2018-05-17 12:12:27 (GMT)
commit4373d115a53f53d86e551e5e760bbfea8374ddb1 (patch)
treeae1e2c21c4ee8e6469145a98c5b4c86be2a1aabf
parent36fe1245a6991518ffae09d1e79a7ddbc4813653 (diff)
Issue #2797047 by quietone, Olarin, Jo Fitzgerald, mradcliffe, niccottrell, heddn, maxocub, mikeryan: Problems creating a d6 user profile field storage with an name longer than 32 characters
-rw-r--r--core/modules/config_translation/migrations/d6_user_profile_field_instance_translation.yml13
-rw-r--r--core/modules/config_translation/tests/src/Kernel/Migrate/d6/MigrateUserProfileFieldInstanceTranslationTest.php2
-rw-r--r--core/modules/migrate_drupal/tests/fixtures/drupal6.php69
-rw-r--r--core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php4
-rw-r--r--core/modules/user/migrations/user_profile_entity_display.yml13
-rw-r--r--core/modules/user/migrations/user_profile_entity_form_display.yml13
-rw-r--r--core/modules/user/migrations/user_profile_field.yml10
-rw-r--r--core/modules/user/migrations/user_profile_field_instance.yml13
-rw-r--r--core/modules/user/src/Plugin/migrate/ProfileValues.php21
-rw-r--r--core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileEntityDisplayTest.php4
-rw-r--r--core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileEntityFormDisplayTest.php2
-rw-r--r--core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileFieldInstanceTest.php4
-rw-r--r--core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserProfileValuesTest.php8
13 files changed, 150 insertions, 26 deletions
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 9b03aa0..0f728f6 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 01d5ec9..c941e41 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 @@ class MigrateUserProfileFieldInstanceTranslationTest extends MigrateDrupal6TestB
]);
$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 7b0eba3..502e263 100644
--- a/core/modules/migrate_drupal/tests/fixtures/drupal6.php
+++ b/core/modules/migrate_drupal/tests/fixtures/drupal6.php
@@ -8802,7 +8802,7 @@ $connection->insert('i18n_strings')
))
->values(array(
'lid' => '509',
- 'objectid' => 'profile_sell_address',
+ 'objectid' => 'profile_sell_Address',
'type' => 'field',
'property' => 'title',
'objectindex' => '0',
@@ -8810,7 +8810,7 @@ $connection->insert('i18n_strings')
))
->values(array(
'lid' => '510',
- 'objectid' => 'profile_sell_address',
+ 'objectid' => 'profile_sell_Address',
'type' => 'field',
'property' => 'explanation',
'objectindex' => '0',
@@ -8890,7 +8890,7 @@ $connection->insert('i18n_strings')
))
->values(array(
'lid' => '520',
- 'objectid' => 'profile_love_migrations',
+ 'objectid' => 'profile_really_really_love_migrations',
'type' => 'field',
'property' => 'title',
'objectindex' => '0',
@@ -8898,7 +8898,7 @@ $connection->insert('i18n_strings')
))
->values(array(
'lid' => '521',
- 'objectid' => 'profile_love_migrations',
+ 'objectid' => 'profile_really_really_love_migrations',
'type' => 'field',
'property' => 'explanation',
'objectindex' => '0',
@@ -9848,6 +9848,14 @@ $connection->insert('i18n_strings')
'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 @@ $connection->insert('locales_source')
))
->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 @@ $connection->insert('locales_source')
))
->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 @@ $connection->insert('locales_source')
'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 @@ $connection->insert('locales_target')
'language' => 'fr',
'plid' => '0',
'plural' => '0',
- 'i18n_status' => '0',
+ 'i18n_status' => '1',
))
->values(array(
'lid' => '521',
@@ -27387,6 +27402,14 @@ $connection->insert('locales_target')
'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',
'language' => 'zu',
@@ -44837,7 +44860,7 @@ $connection->insert('profile_fields')
->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 @@ $connection->insert('profile_fields')
))
->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 @@ $connection->insert('profile_fields')
'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 @@ $connection->insert('profile_values')
'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 2468cd4..abd6b89 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 @@ class MigrateUpgrade6Test extends MigrateUpgradeExecuteTestBase {
'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 7336636..eafba00 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 44a5c53..7416ac8 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 94d7def..af6018e 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 50e0bd2..b6c706c 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 b082d59..8399436 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 @@ class ProfileValues extends Migration {
$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 a4a2036..ac7c181 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 @@ class MigrateUserProfileEntityDisplayTest extends MigrateDrupal6TestBase {
// 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 a2b01aa..2fcec8d 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 @@ class MigrateUserProfileEntityFormDisplayTest extends MigrateDrupal6TestBase {
$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 9713332..ecc9bc9 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 @@ class MigrateUserProfileFieldInstanceTest extends MigrateDrupal6TestBase {
$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 e734517..71acad6 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 @@ EOT;
$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);