diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/CckFieldValues.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/CckFieldValues.php index 60b5fdacca39..5e606e291ac7 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/CckFieldValues.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/CckFieldValues.php @@ -115,7 +115,7 @@ class CckFieldValues extends DrupalSqlBase implements SourceEntityInterface { $source = $row->getSource(); // We diff the results with the source to find any field columns // in the content type's main table. - $new_fields = array_diff($results, $source); + $new_fields = array_diff_key($results, $source); foreach ($new_fields as $key => $value) { $row->setSourceProperty($key, $value); } diff --git a/core/modules/migrate_drupal/src/Tests/Dump/Drupal6FieldInstance.php b/core/modules/migrate_drupal/src/Tests/Dump/Drupal6FieldInstance.php index 65ae0ac22e9f..dafb18f3db75 100644 --- a/core/modules/migrate_drupal/src/Tests/Dump/Drupal6FieldInstance.php +++ b/core/modules/migrate_drupal/src/Tests/Dump/Drupal6FieldInstance.php @@ -790,6 +790,70 @@ class Drupal6FieldInstance extends Drupal6DumpBase { )), 'description' => 'An example multi-valued decimal field.', )) + ->values(array( + 'field_name' => 'field_test_identical1', + 'type_name' => 'story', + 'weight' => 2, + 'label' => 'Integer Field', + 'widget_type' => 'number', + 'widget_settings' => 'a:2:{s:13:"default_value";a:1:{i:0;a:2:{s:5:"value";s:0:"";s:14:"_error_element";s:41:"default_value_widget][field_int][0][value";}}s:17:"default_value_php";N;}', + 'display_settings' => serialize(array( + 'weight' => 2, + 'parent' => '', + 'label' => array( + 'format' => 'above', + ), + 'teaser' => array( + 'format' => 'unformatted', + 'exclude' => 0, + ), + 'full' => array( + 'format' => 'us_0', + 'exclude' => 0, + ), + 4 => array( + 'format' => 'unformatted', + 'exclude' => 0, + ), + 5 => array( + 'format' => 'default', + 'exclude' => 1, + ), + )), + 'description' => 'An example integer field.', + )) + ->values(array( + 'field_name' => 'field_test_identical2', + 'type_name' => 'story', + 'weight' => 2, + 'label' => 'Integer Field', + 'widget_type' => 'number', + 'widget_settings' => 'a:2:{s:13:"default_value";a:1:{i:0;a:2:{s:5:"value";s:0:"";s:14:"_error_element";s:41:"default_value_widget][field_int][0][value";}}s:17:"default_value_php";N;}', + 'display_settings' => serialize(array( + 'weight' => 2, + 'parent' => '', + 'label' => array( + 'format' => 'above', + ), + 'teaser' => array( + 'format' => 'unformatted', + 'exclude' => 0, + ), + 'full' => array( + 'format' => 'us_0', + 'exclude' => 0, + ), + 4 => array( + 'format' => 'unformatted', + 'exclude' => 0, + ), + 5 => array( + 'format' => 'default', + 'exclude' => 1, + ), + )), + 'description' => 'An example integer field.', + )) ->execute(); // Create the field table. @@ -1082,6 +1146,38 @@ Goodbye";s:18:"allowed_values_php";s:0:"";}', 'db_columns' => 'a:1:{s:5:"value";a:5:{s:4:"type";s:7:"numeric";s:9:"precision";s:2:"10";s:5:"scale";s:1:"2";s:8:"not null";b:0;s:8:"sortable";b:1;}}', 'active' => 1, )) + ->values(array( + 'field_name' => 'field_test_identical1', + 'module' => 'number', + 'type' => 'number_integer', + 'global_settings' => '', + 'multiple' => 0, + 'db_storage' => 1, + 'db_columns' => serialize(array( + 'value' => array( + 'type' => 'int', + 'not null' => FALSE, + 'sortable' => TRUE, + ), + )), + 'active' => 1, + )) + ->values(array( + 'field_name' => 'field_test_identical2', + 'module' => 'number', + 'type' => 'number_integer', + 'global_settings' => '', + 'multiple' => 0, + 'db_storage' => 1, + 'db_columns' => serialize(array( + 'value' => array( + 'type' => 'int', + 'not null' => FALSE, + 'sortable' => TRUE, + ), + )), + 'active' => 1, + )) ->execute(); $this->createTable('content_field_test', array( diff --git a/core/modules/migrate_drupal/src/Tests/Dump/Drupal6Node.php b/core/modules/migrate_drupal/src/Tests/Dump/Drupal6Node.php index f20c4b38cf00..11b1582187e4 100644 --- a/core/modules/migrate_drupal/src/Tests/Dump/Drupal6Node.php +++ b/core/modules/migrate_drupal/src/Tests/Dump/Drupal6Node.php @@ -350,6 +350,18 @@ class Drupal6Node extends Drupal6DumpBase { 'unsigned' => FALSE, 'not null' => FALSE ), + 'field_test_identical1_value' => array( + 'description' => 'Test field column.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => FALSE + ), + 'field_test_identical2_value' => array( + 'description' => 'Test field column.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => FALSE + ), ), 'primary key' => array('vid'), )); @@ -361,6 +373,8 @@ class Drupal6Node extends Drupal6DumpBase { 'uid', 'field_test_three_value', 'field_test_integer_selectlist_value', + 'field_test_identical1_value', + 'field_test_identical2_value' )) ->values(array( 'nid' => 1, @@ -368,6 +382,8 @@ class Drupal6Node extends Drupal6DumpBase { 'uid' => 1, 'field_test_three_value' => '42.42', 'field_test_integer_selectlist_value' => '3412', + 'field_test_identical1_value' => 1, + 'field_test_identical2_value' => 1, )) ->execute(); $this->setModuleVersion('content', 6001); diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateCckFieldValuesTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateCckFieldValuesTest.php index 13bf404d3b68..9d21794dccf2 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateCckFieldValuesTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateCckFieldValuesTest.php @@ -83,6 +83,28 @@ class MigrateCckFieldValuesTest extends MigrateNodeTestBase { 'bundle' => 'test_planet', ))->save(); + entity_create('field_storage_config', array( + 'entity_type' => 'node', + 'field_name' => 'field_test_identical1', + 'type' => 'integer', + ))->save(); + entity_create('field_config', array( + 'entity_type' => 'node', + 'field_name' => 'field_test_identical1', + 'bundle' => 'story', + ))->save(); + + entity_create('field_storage_config', array( + 'entity_type' => 'node', + 'field_name' => 'field_test_identical2', + 'type' => 'integer', + ))->save(); + entity_create('field_config', array( + 'entity_type' => 'node', + 'field_name' => 'field_test_identical2', + 'bundle' => 'story', + ))->save(); + // Add some id mappings for the dependant migrations. $id_mappings = array( 'd6_field_formatter_settings' => array( @@ -118,6 +140,8 @@ class MigrateCckFieldValuesTest extends MigrateNodeTestBase { $this->assertEqual($node->field_test_two[1]->value, 20, 'Multi field second value is correct.'); $this->assertEqual($node->field_test_three->value, '42.42', 'Single field second value is correct.'); $this->assertEqual($node->field_test_integer_selectlist[0]->value, '3412', 'Integer select list value is correct'); + $this->assertEqual($node->field_test_identical1->value, '1', 'Integer value is correct'); + $this->assertEqual($node->field_test_identical2->value, '1', 'Integer value is correct'); $planet_node = Node::load(3); $this->assertEqual($planet_node->field_multivalue->value, 33);