Commit 4373d115 authored by catch's avatar catch

Issue #2797047 by quietone, Olarin, Jo Fitzgerald, mradcliffe, niccottrell,...

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
parent 36fe1245
......@@ -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
......
......@@ -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'));
......
......@@ -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(
......@@ -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,
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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) {
......
......@@ -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']);
}
}
......@@ -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']);
}
......
......@@ -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());
}
......
......@@ -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);
......
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