summaryrefslogtreecommitdiffstats
path: root/core/modules/migrate_drupal
diff options
context:
space:
mode:
authorNathaniel Catchpole2018-04-19 12:08:40 (GMT)
committerNathaniel Catchpole2018-04-19 12:08:40 (GMT)
commit7a160733eafe6e26c1a01863958b6484135c8b60 (patch)
tree2c43a5daef532b89011bf35d1f09f63a6a2af14e /core/modules/migrate_drupal
parentfaadb3b23c125a9cb7cfd3bf6abc7117bf552a0d (diff)
Issue #2912348 by maxocub, Jo Fitzgerald, masipila, heddn, phenaproxima: Handle entity_references related to Drupal 6 and 7 node translations with different IDs
Diffstat (limited to 'core/modules/migrate_drupal')
-rw-r--r--core/modules/migrate_drupal/config/install/migrate_drupal.settings.yml5
-rw-r--r--core/modules/migrate_drupal/config/schema/migrate_drupal.schema.yml6
-rw-r--r--core/modules/migrate_drupal/migrate_drupal.install10
-rw-r--r--core/modules/migrate_drupal/migrations/d6_entity_reference_translation.yml22
-rw-r--r--core/modules/migrate_drupal/migrations/d7_entity_reference_translation.yml22
-rw-r--r--core/modules/migrate_drupal/src/MigrationConfigurationTrait.php28
-rw-r--r--core/modules/migrate_drupal/src/Plugin/MigrationWithFollowUpInterface.php40
-rw-r--r--core/modules/migrate_drupal/src/Plugin/migrate/EntityReferenceTranslationDeriver.php189
-rw-r--r--core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php3
-rw-r--r--core/modules/migrate_drupal/tests/fixtures/drupal6.php136
-rw-r--r--core/modules/migrate_drupal/tests/fixtures/drupal7.php598
-rw-r--r--core/modules/migrate_drupal/tests/src/Kernel/d6/FollowUpMigrationsTest.php78
-rw-r--r--core/modules/migrate_drupal/tests/src/Kernel/d7/FollowUpMigrationsTest.php105
13 files changed, 1239 insertions, 3 deletions
diff --git a/core/modules/migrate_drupal/config/install/migrate_drupal.settings.yml b/core/modules/migrate_drupal/config/install/migrate_drupal.settings.yml
index d5a464e..d134dec 100644
--- a/core/modules/migrate_drupal/config/install/migrate_drupal.settings.yml
+++ b/core/modules/migrate_drupal/config/install/migrate_drupal.settings.yml
@@ -3,3 +3,8 @@
enforce_source_module_tags:
- Drupal 6
- Drupal 7
+# Migrations with any of these tags will not be derived and executed with the
+# other migrations. They will be derived and executed after the migrations on
+# which they depend have been successfully executed.
+follow_up_migration_tags:
+ - Follow-up migration
diff --git a/core/modules/migrate_drupal/config/schema/migrate_drupal.schema.yml b/core/modules/migrate_drupal/config/schema/migrate_drupal.schema.yml
index e980081..1b09e06 100644
--- a/core/modules/migrate_drupal/config/schema/migrate_drupal.schema.yml
+++ b/core/modules/migrate_drupal/config/schema/migrate_drupal.schema.yml
@@ -8,3 +8,9 @@ migrate_drupal.settings:
sequence:
type: string
label: 'Tag'
+ follow_up_migration_tags:
+ type: sequence
+ label: 'Follow-up migration tags'
+ sequence:
+ type: string
+ label: 'Tag'
diff --git a/core/modules/migrate_drupal/migrate_drupal.install b/core/modules/migrate_drupal/migrate_drupal.install
index 0ef88af..ed60201 100644
--- a/core/modules/migrate_drupal/migrate_drupal.install
+++ b/core/modules/migrate_drupal/migrate_drupal.install
@@ -14,3 +14,13 @@ function migrate_drupal_update_8501() {
->set('enforce_source_module_tags', ['Drupal 6', 'Drupal 7'])
->save();
}
+
+/**
+ * Sets the follow-up migration tags.
+ */
+function migrate_drupal_update_8502() {
+ \Drupal::configFactory()
+ ->getEditable('migrate_drupal.settings')
+ ->set('follow_up_migration_tags', ['Follow-up migration'])
+ ->save();
+}
diff --git a/core/modules/migrate_drupal/migrations/d6_entity_reference_translation.yml b/core/modules/migrate_drupal/migrations/d6_entity_reference_translation.yml
new file mode 100644
index 0000000..3188820
--- /dev/null
+++ b/core/modules/migrate_drupal/migrations/d6_entity_reference_translation.yml
@@ -0,0 +1,22 @@
+id: d6_entity_reference_translation
+label: Entity reference translations
+migration_tags:
+ - Drupal 6
+ - Follow-up migration
+deriver: Drupal\migrate_drupal\Plugin\migrate\EntityReferenceTranslationDeriver
+# Supported target types for entity reference translation migrations. The array
+# keys are the supported target types and the values are arrays of migrations
+# to lookup for the translated entity IDs.
+target_types:
+ node:
+ - d6_node_translation
+# The source plugin will be set by the deriver.
+source:
+ plugin: empty
+ key: default
+ target: default
+# The process pipeline will be set by the deriver.
+process: []
+# The destination plugin will be set by the deriver.
+destination:
+ plugin: null
diff --git a/core/modules/migrate_drupal/migrations/d7_entity_reference_translation.yml b/core/modules/migrate_drupal/migrations/d7_entity_reference_translation.yml
new file mode 100644
index 0000000..7e59a9a
--- /dev/null
+++ b/core/modules/migrate_drupal/migrations/d7_entity_reference_translation.yml
@@ -0,0 +1,22 @@
+id: d7_entity_reference_translation
+label: Entity reference translations
+migration_tags:
+ - Drupal 7
+ - Follow-up migration
+deriver: Drupal\migrate_drupal\Plugin\migrate\EntityReferenceTranslationDeriver
+# Supported target types for entity reference translation migrations. The array
+# keys are the supported target types and the values are arrays of migrations
+# to lookup for the translated entity IDs.
+target_types:
+ node:
+ - d7_node_translation
+# The source plugin will be set by the deriver.
+source:
+ plugin: empty
+ key: default
+ target: default
+# The process pipeline will be set by the deriver.
+process: []
+# The destination plugin will be set by the deriver.
+destination:
+ plugin: null
diff --git a/core/modules/migrate_drupal/src/MigrationConfigurationTrait.php b/core/modules/migrate_drupal/src/MigrationConfigurationTrait.php
index b566c82..0aca5be 100644
--- a/core/modules/migrate_drupal/src/MigrationConfigurationTrait.php
+++ b/core/modules/migrate_drupal/src/MigrationConfigurationTrait.php
@@ -13,6 +13,13 @@ use Drupal\migrate\Plugin\RequirementsInterface;
trait MigrationConfigurationTrait {
/**
+ * The follow-up migration tags.
+ *
+ * @var string[]
+ */
+ protected $followUpMigrationTags;
+
+ /**
* Gets the database connection for the source Drupal database.
*
* @param array $database
@@ -96,6 +103,13 @@ trait MigrationConfigurationTrait {
$all_migrations = $plugin_manager->createInstancesByTag($version_tag);
$migrations = [];
foreach ($all_migrations as $migration) {
+ // Skip migrations tagged with any of the follow-up migration tags. They
+ // will be derived and executed after the migrations on which they depend
+ // have been successfully executed.
+ // @see Drupal\migrate_drupal\Plugin\MigrationWithFollowUpInterface
+ if (!empty(array_intersect($migration->getMigrationTags(), $this->getFollowUpMigrationTags()))) {
+ continue;
+ }
try {
// @todo https://drupal.org/node/2681867 We should be able to validate
// the entire migration at this point.
@@ -120,6 +134,20 @@ trait MigrationConfigurationTrait {
}
/**
+ * Returns the follow-up migration tags.
+ *
+ * @return string[]
+ */
+ protected function getFollowUpMigrationTags() {
+ if ($this->followUpMigrationTags === NULL) {
+ $this->followUpMigrationTags = \Drupal::configFactory()
+ ->get('migrate_drupal.settings')
+ ->get('follow_up_migration_tags') ?: [];
+ }
+ return $this->followUpMigrationTags;
+ }
+
+ /**
* Determines what version of Drupal the source database contains.
*
* @param \Drupal\Core\Database\Connection $connection
diff --git a/core/modules/migrate_drupal/src/Plugin/MigrationWithFollowUpInterface.php b/core/modules/migrate_drupal/src/Plugin/MigrationWithFollowUpInterface.php
new file mode 100644
index 0000000..93ef8f9
--- /dev/null
+++ b/core/modules/migrate_drupal/src/Plugin/MigrationWithFollowUpInterface.php
@@ -0,0 +1,40 @@
+<?php
+
+namespace Drupal\migrate_drupal\Plugin;
+
+/**
+ * Interface for migrations with follow-up migrations.
+ *
+ * Some migrations need to be derived and executed after other migrations have
+ * been successfully executed. For example, a migration might need to be derived
+ * based on previously migrated data. For such a case, the migration dependency
+ * system is not enough since all migrations would still be derived before any
+ * one of them has been executed.
+ *
+ * Those "follow-up" migrations need to be tagged with the "Follow-up migration"
+ * tag (or any tag in the "follow_up_migration_tags" configuration) and thus
+ * they won't be derived with the other migrations.
+ *
+ * To get those follow-up migrations derived at the right time, the migrations
+ * on which they depend must implement this interface and generate them in the
+ * generateFollowUpMigrations() method.
+ *
+ * When the migrations implementing this interface have been successfully
+ * executed, the follow-up migrations will then be derived having access to the
+ * now migrated data.
+ */
+interface MigrationWithFollowUpInterface {
+
+ /**
+ * Generates follow-up migrations.
+ *
+ * When the migration implementing this interface has been succesfully
+ * executed, this method will be used to generate the follow-up migrations
+ * which depends on the now migrated data.
+ *
+ * @return \Drupal\migrate\Plugin\MigrationInterface[]
+ * The follow-up migrations.
+ */
+ public function generateFollowUpMigrations();
+
+}
diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/EntityReferenceTranslationDeriver.php b/core/modules/migrate_drupal/src/Plugin/migrate/EntityReferenceTranslationDeriver.php
new file mode 100644
index 0000000..d81b92c
--- /dev/null
+++ b/core/modules/migrate_drupal/src/Plugin/migrate/EntityReferenceTranslationDeriver.php
@@ -0,0 +1,189 @@
+<?php
+
+namespace Drupal\migrate_drupal\Plugin\migrate;
+
+use Drupal\Component\Plugin\Derivative\DeriverBase;
+use Drupal\Component\Plugin\PluginBase;
+use Drupal\Core\Entity\EntityFieldManagerInterface;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
+use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Deriver for entity reference field translations.
+ *
+ * A migration will be created for every bundle with at least one entity
+ * reference field that is configured to point to one of the supported target
+ * entity types. The migrations will update the entity reference fields with
+ * values found in the mapping tables of the migrations associated with the
+ * target types.
+ *
+ * Example:
+ *
+ * @code
+ * id: d7_entity_reference_translation
+ * label: Entity reference translations
+ * migration_tags:
+ * - Drupal 7
+ * - Follow-up migration
+ * deriver: Drupal\migrate_drupal\Plugin\migrate\EntityReferenceTranslationDeriver
+ * target_types:
+ * node:
+ * - d7_node_translation
+ * source:
+ * plugin: empty
+ * key: default
+ * target: default
+ * process: []
+ * destination:
+ * plugin: null
+ * @endcode
+ *
+ * In this example, the only supported target type is 'node' and the associated
+ * migration for the mapping table lookup is 'd7_node_translation'.
+ */
+class EntityReferenceTranslationDeriver extends DeriverBase implements ContainerDeriverInterface {
+
+ use StringTranslationTrait;
+
+ /**
+ * The entity field manager.
+ *
+ * @var \Drupal\Core\Entity\EntityFieldManagerInterface
+ */
+ protected $entityFieldManager;
+
+ /**
+ * The entity type manager.
+ *
+ * @var \Drupal\Core\Entity\EntityTypeManagerInterface
+ */
+ protected $entityTypeManager;
+
+ /**
+ * EntityReferenceTranslationDeriver constructor.
+ *
+ * @param string $base_plugin_id
+ * The base plugin ID.
+ * @param \Drupal\core\Entity\EntityFieldManagerInterface $entity_field_manager
+ * The entity field manager.
+ * @param \Drupal\core\Entity\EntityTypeManagerInterface $entity_type_manager
+ * The entity type manager.
+ */
+ public function __construct($base_plugin_id, EntityFieldManagerInterface $entity_field_manager, EntityTypeManagerInterface $entity_type_manager) {
+ $this->entityFieldManager = $entity_field_manager;
+ $this->entityTypeManager = $entity_type_manager;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container, $base_plugin_id) {
+ return new static(
+ $base_plugin_id,
+ $container->get('entity_field.manager'),
+ $container->get('entity_type.manager')
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getDerivativeDefinitions($base_plugin_definition) {
+ // Get all entity reference fields.
+ $field_map = $this->entityFieldManager->getFieldMapByFieldType('entity_reference');
+
+ foreach ($field_map as $entity_type => $fields) {
+ foreach ($fields as $field_name => $field) {
+ foreach ($field['bundles'] as $bundle) {
+ $field_definitions = $this->entityFieldManager->getFieldDefinitions($entity_type, $bundle);
+ $target_type = $field_definitions[$field_name]->getSetting('target_type');
+
+ // If the field's target type is not supported, skip it.
+ if (!array_key_exists($target_type, $base_plugin_definition['target_types'])) {
+ continue;
+ }
+
+ // Key derivatives by entity types and bundles.
+ $derivative_key = $entity_type . '__' . $bundle;
+
+ $derivative = $base_plugin_definition;
+
+ // Set the migration label.
+ $derivative['label'] = $this->t('@label (@derivative)', [
+ '@label' => $base_plugin_definition['label'],
+ '@derivative' => $derivative_key,
+ ]);
+
+ // Set the source plugin.
+ $derivative['source']['plugin'] = 'content_entity' . PluginBase::DERIVATIVE_SEPARATOR . $entity_type;
+ $derivative['source']['bundle'] = $bundle;
+
+ // Set the process pipeline.
+ $entity_type_definition = $this->entityTypeManager->getDefinition($entity_type);
+ $id_key = $entity_type_definition->getKey('id');
+ $derivative['process'][$id_key] = $id_key;
+ if ($entity_type_definition->isRevisionable()) {
+ $revision_key = $entity_type_definition->getKey('revision');
+ $derivative['process'][$revision_key] = $revision_key;
+ }
+ if ($entity_type_definition->isTranslatable()) {
+ $langcode_key = $entity_type_definition->getKey('langcode');
+ $derivative['process'][$langcode_key] = $langcode_key;
+ }
+
+ // Set the destination plugin.
+ $derivative['destination']['plugin'] = 'entity' . PluginBase::DERIVATIVE_SEPARATOR . $entity_type;
+ $derivative['destination']['default_bundle'] = $bundle;
+ if ($entity_type_definition->isTranslatable()) {
+ $derivative['destination']['translations'] = TRUE;
+ }
+
+ // Allow overwriting the entity reference field so we can update its
+ // values with the ones found in the mapping table.
+ $derivative['destination']['overwrite_properties'][$field_name] = $field_name;
+
+ // Add the entity reference field to the process pipeline.
+ $derivative['process'][$field_name] = [
+ 'plugin' => 'sub_process',
+ 'source' => $field_name,
+ 'process' => [
+ 'target_id' => [
+ [
+ 'plugin' => 'migration_lookup',
+ 'source' => 'target_id',
+ 'migration' => $base_plugin_definition['target_types'][$target_type],
+ 'no_stub' => TRUE,
+ ],
+ [
+ 'plugin' => 'skip_on_empty',
+ 'method' => 'row',
+ ],
+ [
+ 'plugin' => 'extract',
+ 'index' => [0],
+ ],
+ ],
+ ],
+ ];
+
+ if (!isset($this->derivatives[$derivative_key])) {
+ // If this is a new derivative, add it to the returned derivatives.
+ $this->derivatives[$derivative_key] = $derivative;
+ }
+ else {
+ // If this is an existing derivative, it means this bundle has more
+ // than one entity reference field. In that case, we only want to add
+ // the field to the process pipeline and make it overwritable.
+ $this->derivatives[$derivative_key]['process'] += $derivative['process'];
+ $this->derivatives[$derivative_key]['destination']['overwrite_properties'] += $derivative['destination']['overwrite_properties'];
+ }
+ }
+ }
+ }
+
+ return $this->derivatives;
+ }
+
+}
diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php b/core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php
index e8c2dd5..d8b756b 100644
--- a/core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php
+++ b/core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php
@@ -26,8 +26,7 @@ class NodeReference extends FieldPluginBase {
'source' => $field_name,
'process' => [
'target_id' => [
- 'plugin' => 'migration_lookup',
- 'migration' => 'd6_node',
+ 'plugin' => 'get',
'source' => 'nid',
],
],
diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal6.php b/core/modules/migrate_drupal/tests/fixtures/drupal6.php
index 4d4e18b..7b0eba3 100644
--- a/core/modules/migrate_drupal/tests/fixtures/drupal6.php
+++ b/core/modules/migrate_drupal/tests/fixtures/drupal6.php
@@ -2753,6 +2753,30 @@ $connection->insert('content_node_field')
'locked' => '0',
))
->values(array(
+ 'field_name' => 'field_reference',
+ 'type' => 'nodereference',
+ 'global_settings' => 'a:1:{s:19:"referenceable_types";a:11:{s:4:"page";s:4:"page";s:7:"article";i:0;s:7:"company";i:0;s:8:"employee";i:0;s:5:"forum";i:0;s:10:"test_event";i:0;s:9:"test_page";i:0;s:11:"test_planet";i:0;s:10:"test_story";i:0;s:7:"sponsor";i:0;s:5:"story";i:0;}}',
+ 'required' => '0',
+ 'multiple' => '0',
+ 'db_storage' => '1',
+ 'module' => 'nodereference',
+ 'db_columns' => 'a:1:{s:3:"nid";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:0;s:5:"index";b:1;}}',
+ 'active' => '1',
+ 'locked' => '0',
+))
+->values(array(
+ 'field_name' => 'field_reference_2',
+ 'type' => 'nodereference',
+ 'global_settings' => 'a:1:{s:19:"referenceable_types";a:11:{s:4:"page";s:4:"page";s:7:"article";i:0;s:7:"company";i:0;s:8:"employee";i:0;s:5:"forum";i:0;s:10:"test_event";i:0;s:9:"test_page";i:0;s:11:"test_planet";i:0;s:10:"test_story";i:0;s:7:"sponsor";i:0;s:5:"story";i:0;}}',
+ 'required' => '0',
+ 'multiple' => '0',
+ 'db_storage' => '1',
+ 'module' => 'nodereference',
+ 'db_columns' => 'a:1:{s:3:"nid";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:0;s:5:"index";b:1;}}',
+ 'active' => '1',
+ 'locked' => '0',
+))
+->values(array(
'field_name' => 'field_test',
'type' => 'text',
'global_settings' => 'a:4:{s:15:"text_processing";s:1:"1";s:10:"max_length";s:0:"";s:14:"allowed_values";s:0:"";s:18:"allowed_values_php";s:0:"";}',
@@ -3135,6 +3159,30 @@ $connection->insert('content_node_field_instance')
'widget_active' => '1',
))
->values(array(
+ 'field_name' => 'field_reference',
+ 'type_name' => 'page',
+ 'weight' => '31',
+ 'label' => 'Reference',
+ 'widget_type' => 'nodereference_select',
+ 'widget_settings' => 'a:4:{s:18:"autocomplete_match";s:8:"contains";s:4:"size";i:60;s:13:"default_value";a:1:{i:0;a:1:{s:3:"nid";s:0:"";}}s:17:"default_value_php";N;}',
+ 'display_settings' => 'a:5:{s:5:"label";a:2:{s:6:"format";s:5:"above";s:7:"exclude";i:0;}i:5;a:2:{s:6:"format";s:7:"default";s:7:"exclude";i:0;}s:6:"teaser";a:2:{s:6:"format";s:7:"default";s:7:"exclude";i:0;}s:4:"full";a:2:{s:6:"format";s:7:"default";s:7:"exclude";i:0;}i:4;a:2:{s:6:"format";s:7:"default";s:7:"exclude";i:0;}}',
+ 'description' => '',
+ 'widget_module' => 'nodereference',
+ 'widget_active' => '1',
+))
+->values(array(
+ 'field_name' => 'field_reference_2',
+ 'type_name' => 'page',
+ 'weight' => '32',
+ 'label' => 'Reference',
+ 'widget_type' => 'nodereference_select',
+ 'widget_settings' => 'a:4:{s:18:"autocomplete_match";s:8:"contains";s:4:"size";i:60;s:13:"default_value";a:1:{i:0;a:1:{s:3:"nid";s:0:"";}}s:17:"default_value_php";N;}',
+ 'display_settings' => 'a:5:{s:5:"label";a:2:{s:6:"format";s:5:"above";s:7:"exclude";i:0;}i:5;a:2:{s:6:"format";s:7:"default";s:7:"exclude";i:0;}s:6:"teaser";a:2:{s:6:"format";s:7:"default";s:7:"exclude";i:0;}s:4:"full";a:2:{s:6:"format";s:7:"default";s:7:"exclude";i:0;}i:4;a:2:{s:6:"format";s:7:"default";s:7:"exclude";i:0;}}',
+ 'description' => '',
+ 'widget_module' => 'nodereference',
+ 'widget_active' => '1',
+))
+->values(array(
'field_name' => 'field_test',
'type_name' => 'story',
'weight' => '1',
@@ -3493,13 +3541,71 @@ $connection->schema()->createTable('content_type_page', array(
'not null' => FALSE,
'size' => 'normal',
),
+ 'field_reference_nid' => array(
+ 'type' => 'int',
+ 'not null' => FALSE,
+ 'size' => 'normal',
+ 'unsigned' => TRUE,
+ ),
+ 'field_reference_2_nid' => array(
+ 'type' => 'int',
+ 'not null' => FALSE,
+ 'size' => 'normal',
+ 'unsigned' => TRUE,
+ ),
),
'primary key' => array(
'vid',
),
+ 'indexes' => array(
+ 'field_reference_nid' => array(
+ 'field_reference_nid',
+ ),
+ 'field_reference_2_nid' => array(
+ 'field_reference_2_nid',
+ ),
+ ),
'mysql_character_set' => 'utf8',
));
+$connection->insert('content_type_page')
+->fields(array(
+ 'vid',
+ 'nid',
+ 'field_text_field_value',
+ 'field_reference_nid',
+ 'field_reference_2_nid',
+))
+->values(array(
+ 'vid' => '13',
+ 'nid' => '10',
+ 'field_text_field_value' => NULL,
+ 'field_reference_nid' => '13',
+ 'field_reference_2_nid' => '13',
+))
+->values(array(
+ 'vid' => '14',
+ 'nid' => '11',
+ 'field_text_field_value' => NULL,
+ 'field_reference_nid' => '20',
+ 'field_reference_2_nid' => '20',
+))
+->values(array(
+ 'vid' => '16',
+ 'nid' => '13',
+ 'field_text_field_value' => NULL,
+ 'field_reference_nid' => '10',
+ 'field_reference_2_nid' => '10',
+))
+->values(array(
+ 'vid' => '23',
+ 'nid' => '20',
+ 'field_text_field_value' => NULL,
+ 'field_reference_nid' => '11',
+ 'field_reference_2_nid' => '11',
+))
+->execute();
+
$connection->schema()->createTable('content_type_story', array(
'fields' => array(
'nid' => array(
@@ -43548,6 +43654,23 @@ $connection->insert('node')
'tnid' => '0',
'translate' => '0',
))
+->values(array(
+ 'nid' => '20',
+ 'vid' => '23',
+ 'type' => 'page',
+ 'language' => 'fr',
+ 'title' => 'Le peuple zoulou',
+ 'uid' => '1',
+ 'status' => '1',
+ 'created' => '1520613038',
+ 'changed' => '1520613305',
+ 'comment' => '0',
+ 'promote' => '1',
+ 'moderate' => '0',
+ 'sticky' => '0',
+ 'tnid' => '12',
+ 'translate' => '0',
+))
->execute();
$connection->schema()->createTable('node_access', array(
@@ -44206,6 +44329,17 @@ $connection->insert('node_revisions')
'timestamp' => '1501955771',
'format' => '1',
))
+->values(array(
+ 'nid' => '20',
+ 'vid' => '23',
+ 'uid' => '1',
+ 'title' => 'Le peuple zoulou',
+ 'body' => 'Le peuple zoulou.',
+ 'teaser' => 'Le peuple zoulou.',
+ 'log' => '',
+ 'timestamp' => '1520613305',
+ 'format' => '1',
+))
->execute();
$connection->schema()->createTable('node_type', array(
@@ -44472,7 +44606,7 @@ $connection->insert('node_type')
'custom' => '1',
'modified' => '1',
'locked' => '0',
- 'orig_type' => 'page',
+ 'orig_type' => 'test_page',
))
->values(array(
'type' => 'test_planet',
diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal7.php b/core/modules/migrate_drupal/tests/fixtures/drupal7.php
index 6f61f67..d77940e 100644
--- a/core/modules/migrate_drupal/tests/fixtures/drupal7.php
+++ b/core/modules/migrate_drupal/tests/fixtures/drupal7.php
@@ -3649,6 +3649,36 @@ $connection->insert('field_config')
'translatable' => '0',
'deleted' => '0',
))
+->values(array(
+ 'id' => '38',
+ 'field_name' => 'field_reference',
+ 'type' => 'entityreference',
+ 'module' => 'entityreference',
+ 'active' => '1',
+ 'storage_type' => 'field_sql_storage',
+ 'storage_module' => 'field_sql_storage',
+ 'storage_active' => '1',
+ 'locked' => '0',
+ 'data' => 'a:7:{s:12:"translatable";s:1:"0";s:12:"entity_types";a:0:{}s:8:"settings";a:3:{s:11:"target_type";s:4:"node";s:7:"handler";s:4:"base";s:16:"handler_settings";a:2:{s:14:"target_bundles";a:1:{s:7:"article";s:7:"article";}s:4:"sort";a:1:{s:4:"type";s:4:"none";}}}s:7:"storage";a:5:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";s:7:"details";a:1:{s:3:"sql";a:2:{s:18:"FIELD_LOAD_CURRENT";a:1:{s:26:"field_data_field_reference";a:1:{s:9:"target_id";s:25:"field_reference_target_id";}}s:19:"FIELD_LOAD_REVISION";a:1:{s:30:"field_revision_field_reference";a:1:{s:9:"target_id";s:25:"field_reference_target_id";}}}}}s:12:"foreign keys";a:1:{s:4:"node";a:2:{s:5:"table";s:4:"node";s:7:"columns";a:1:{s:9:"target_id";s:3:"nid";}}}s:7:"indexes";a:1:{s:9:"target_id";a:1:{i:0;s:9:"target_id";}}s:2:"id";s:2:"37";}',
+ 'cardinality' => '1',
+ 'translatable' => '0',
+ 'deleted' => '0',
+))
+->values(array(
+ 'id' => '39',
+ 'field_name' => 'field_reference_2',
+ 'type' => 'entityreference',
+ 'module' => 'entityreference',
+ 'active' => '1',
+ 'storage_type' => 'field_sql_storage',
+ 'storage_module' => 'field_sql_storage',
+ 'storage_active' => '1',
+ 'locked' => '0',
+ 'data' => 'a:7:{s:12:"translatable";s:1:"0";s:12:"entity_types";a:0:{}s:8:"settings";a:3:{s:11:"target_type";s:4:"node";s:7:"handler";s:4:"base";s:16:"handler_settings";a:2:{s:14:"target_bundles";a:1:{s:7:"article";s:7:"article";}s:4:"sort";a:1:{s:4:"type";s:4:"none";}}}s:7:"storage";a:5:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";s:7:"details";a:1:{s:3:"sql";a:2:{s:18:"FIELD_LOAD_CURRENT";a:1:{s:28:"field_data_field_reference_2";a:1:{s:9:"target_id";s:27:"field_reference_2_target_id";}}s:19:"FIELD_LOAD_REVISION";a:1:{s:32:"field_revision_field_reference_2";a:1:{s:9:"target_id";s:27:"field_reference_2_target_id";}}}}}s:12:"foreign keys";a:1:{s:4:"node";a:2:{s:5:"table";s:4:"node";s:7:"columns";a:1:{s:9:"target_id";s:3:"nid";}}}s:7:"indexes";a:1:{s:9:"target_id";a:1:{i:0;s:9:"target_id";}}s:2:"id";s:2:"39";}',
+ 'cardinality' => '1',
+ 'translatable' => '0',
+ 'deleted' => '0',
+))
->execute();
$connection->schema()->createTable('field_config_instance', array(
@@ -4258,6 +4288,24 @@ $connection->insert('field_config_instance')
'data' => 'a:7:{s:5:"label";s:10:"Float List";s:6:"widget";a:5:{s:6:"weight";s:2:"20";s:4:"type";s:14:"options_select";s:6:"module";s:7:"options";s:6:"active";i:1;s:8:"settings";a:0:{}}s:8:"settings";a:1:{s:18:"user_register_form";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:12:"list_default";s:8:"settings";a:0:{}s:6:"module";s:4:"list";s:6:"weight";i:19;}}s:8:"required";i:0;s:11:"description";s:0:"";s:13:"default_value";N;}',
'deleted' => '0',
))
+->values(array(
+ 'id' => '64',
+ 'field_id' => '38',
+ 'field_name' => 'field_reference',
+ 'entity_type' => 'node',
+ 'bundle' => 'article',
+ 'data' => 'a:7:{s:5:"label";s:9:"Reference";s:6:"widget";a:5:{s:6:"weight";s:2:"20";s:4:"type";s:14:"options_select";s:6:"module";s:7:"options";s:6:"active";i:1;s:8:"settings";a:0:{}}s:8:"settings";a:1:{s:18:"user_register_form";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:21:"entityreference_label";s:6:"weight";s:2:"20";s:8:"settings";a:2:{s:13:"bypass_access";i:0;s:4:"link";i:1;}s:6:"module";s:15:"entityreference";}}s:8:"required";i:0;s:11:"description";s:0:"";s:13:"default_value";N;}',
+ 'deleted' => '0',
+))
+->values(array(
+ 'id' => '65',
+ 'field_id' => '39',
+ 'field_name' => 'field_reference_2',
+ 'entity_type' => 'node',
+ 'bundle' => 'article',
+ 'data' => 'a:6:{s:5:"label";s:11:"Reference 2";s:6:"widget";a:4:{s:4:"type";s:14:"options_select";s:6:"weight";s:2:"21";s:8:"settings";a:0:{}s:6:"module";s:7:"options";}s:8:"settings";a:1:{s:18:"user_register_form";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:21:"entityreference_label";s:8:"settings";a:2:{s:4:"link";b:0;s:13:"bypass_access";b:0;}s:6:"module";s:15:"entityreference";s:6:"weight";i:21;}}s:8:"required";b:0;s:11:"description";s:0:"";}',
+ 'deleted' => '0',
+))
->execute();
$connection->schema()->createTable('field_data_body', array(
@@ -6165,6 +6213,280 @@ $connection->insert('field_data_field_private_file')
))
->execute();
+$connection->schema()->createTable('field_data_field_reference', array(
+ 'fields' => array(
+ 'entity_type' => array(
+ 'type' => 'varchar',
+ 'not null' => TRUE,
+ 'length' => '128',
+ 'default' => '',
+ ),
+ 'bundle' => array(
+ 'type' => 'varchar',
+ 'not null' => TRUE,
+ 'length' => '128',
+ 'default' => '',
+ ),
+ 'deleted' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'size' => 'tiny',
+ 'default' => '0',
+ ),
+ 'entity_id' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'size' => 'normal',
+ 'unsigned' => TRUE,
+ ),
+ 'revision_id' => array(
+ 'type' => 'int',
+ 'not null' => FALSE,
+ 'size' => 'normal',
+ 'unsigned' => TRUE,
+ ),
+ 'language' => array(
+ 'type' => 'varchar',
+ 'not null' => TRUE,
+ 'length' => '32',
+ 'default' => '',
+ ),
+ 'delta' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'size' => 'normal',
+ 'unsigned' => TRUE,
+ ),
+ 'field_reference_target_id' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'size' => 'normal',
+ 'unsigned' => TRUE,
+ ),
+ ),
+ 'primary key' => array(
+ 'entity_type',
+ 'entity_id',
+ 'deleted',
+ 'delta',
+ 'language',
+ ),
+ 'indexes' => array(
+ 'entity_type' => array(
+ 'entity_type',
+ ),
+ 'bundle' => array(
+ 'bundle',
+ ),
+ 'deleted' => array(
+ 'deleted',
+ ),
+ 'entity_id' => array(
+ 'entity_id',
+ ),
+ 'revision_id' => array(
+ 'revision_id',
+ ),
+ 'language' => array(
+ 'language',
+ ),
+ 'field_reference_target_id' => array(
+ 'field_reference_target_id',
+ ),
+ ),
+ 'mysql_character_set' => 'utf8',
+));
+
+$connection->insert('field_data_field_reference')
+->fields(array(
+ 'entity_type',
+ 'bundle',
+ 'deleted',
+ 'entity_id',
+ 'revision_id',
+ 'language',
+ 'delta',
+ 'field_reference_target_id',
+))
+->values(array(
+ 'entity_type' => 'node',
+ 'bundle' => 'article',
+ 'deleted' => '0',
+ 'entity_id' => '2',
+ 'revision_id' => '2',
+ 'language' => 'und',
+ 'delta' => '0',
+ 'field_reference_target_id' => '5',
+))
+->values(array(
+ 'entity_type' => 'node',
+ 'bundle' => 'article',
+ 'deleted' => '0',
+ 'entity_id' => '3',
+ 'revision_id' => '3',
+ 'language' => 'und',
+ 'delta' => '0',
+ 'field_reference_target_id' => '4',
+))
+->values(array(
+ 'entity_type' => 'node',
+ 'bundle' => 'article',
+ 'deleted' => '0',
+ 'entity_id' => '4',
+ 'revision_id' => '4',
+ 'language' => 'und',
+ 'delta' => '0',
+ 'field_reference_target_id' => '3',
+))
+->values(array(
+ 'entity_type' => 'node',
+ 'bundle' => 'article',
+ 'deleted' => '0',
+ 'entity_id' => '5',
+ 'revision_id' => '5',
+ 'language' => 'und',
+ 'delta' => '0',
+ 'field_reference_target_id' => '2',
+))
+->execute();
+
+$connection->schema()->createTable('field_data_field_reference_2', array(
+ 'fields' => array(
+ 'entity_type' => array(
+ 'type' => 'varchar',
+ 'not null' => TRUE,
+ 'length' => '128',
+ 'default' => '',
+ ),
+ 'bundle' => array(
+ 'type' => 'varchar',
+ 'not null' => TRUE,
+ 'length' => '128',
+ 'default' => '',
+ ),
+ 'deleted' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'size' => 'tiny',
+ 'default' => '0',
+ ),
+ 'entity_id' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'size' => 'normal',
+ 'unsigned' => TRUE,
+ ),
+ 'revision_id' => array(
+ 'type' => 'int',
+ 'not null' => FALSE,
+ 'size' => 'normal',
+ 'unsigned' => TRUE,
+ ),
+ 'language' => array(
+ 'type' => 'varchar',
+ 'not null' => TRUE,
+ 'length' => '32',
+ 'default' => '',
+ ),
+ 'delta' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'size' => 'normal',
+ 'unsigned' => TRUE,
+ ),
+ 'field_reference_2_target_id' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'size' => 'normal',
+ 'unsigned' => TRUE,
+ ),
+ ),
+ 'primary key' => array(
+ 'entity_type',
+ 'entity_id',
+ 'deleted',
+ 'delta',
+ 'language',
+ ),
+ 'indexes' => array(
+ 'entity_type' => array(
+ 'entity_type',
+ ),
+ 'bundle' => array(
+ 'bundle',
+ ),
+ 'deleted' => array(
+ 'deleted',
+ ),
+ 'entity_id' => array(
+ 'entity_id',
+ ),
+ 'revision_id' => array(
+ 'revision_id',
+ ),
+ 'language' => array(
+ 'language',
+ ),
+ 'field_reference_2_target_id' => array(
+ 'field_reference_2_target_id',
+ ),
+ ),
+ 'mysql_character_set' => 'utf8',
+));
+
+$connection->insert('field_data_field_reference_2')
+->fields(array(
+ 'entity_type',
+ 'bundle',
+ 'deleted',
+ 'entity_id',
+ 'revision_id',
+ 'language',
+ 'delta',
+ 'field_reference_2_target_id',
+))
+->values(array(
+ 'entity_type' => 'node',
+ 'bundle' => 'article',
+ 'deleted' => '0',
+ 'entity_id' => '2',
+ 'revision_id' => '2',
+ 'language' => 'und',
+ 'delta' => '0',
+ 'field_reference_2_target_id' => '5',
+))
+->values(array(
+ 'entity_type' => 'node',
+ 'bundle' => 'article',
+ 'deleted' => '0',
+ 'entity_id' => '3',
+ 'revision_id' => '3',
+ 'language' => 'und',
+ 'delta' => '0',
+ 'field_reference_2_target_id' => '4',
+))
+->values(array(
+ 'entity_type' => 'node',
+ 'bundle' => 'article',
+ 'deleted' => '0',
+ 'entity_id' => '4',
+ 'revision_id' => '4',
+ 'language' => 'und',
+ 'delta' => '0',
+ 'field_reference_2_target_id' => '3',
+))
+->values(array(
+ 'entity_type' => 'node',
+ 'bundle' => 'article',
+ 'deleted' => '0',
+ 'entity_id' => '5',
+ 'revision_id' => '5',
+ 'language' => 'und',
+ 'delta' => '0',
+ 'field_reference_2_target_id' => '2',
+))
+->execute();
+
$connection->schema()->createTable('field_data_field_tags', array(
'fields' => array(
'entity_type' => array(
@@ -9650,6 +9972,282 @@ $connection->insert('field_revision_field_private_file')
))
->execute();
+$connection->schema()->createTable('field_revision_field_reference', array(
+ 'fields' => array(
+ 'entity_type' => array(
+ 'type' => 'varchar',
+ 'not null' => TRUE,
+ 'length' => '128',
+ 'default' => '',
+ ),
+ 'bundle' => array(
+ 'type' => 'varchar',
+ 'not null' => TRUE,
+ 'length' => '128',
+ 'default' => '',
+ ),
+ 'deleted' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'size' => 'tiny',
+ 'default' => '0',
+ ),
+ 'entity_id' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'size' => 'normal',
+ 'unsigned' => TRUE,
+ ),
+ 'revision_id' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'size' => 'normal',
+ 'unsigned' => TRUE,
+ ),
+ 'language' => array(
+ 'type' => 'varchar',
+ 'not null' => TRUE,
+ 'length' => '32',
+ 'default' => '',
+ ),
+ 'delta' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'size' => 'normal',
+ 'unsigned' => TRUE,
+ ),
+ 'field_reference_target_id' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'size' => 'normal',
+ 'unsigned' => TRUE,
+ ),
+ ),
+ 'primary key' => array(
+ 'entity_type',
+ 'entity_id',
+ 'revision_id',
+ 'deleted',
+ 'delta',
+ 'language',
+ ),
+ 'indexes' => array(
+ 'entity_type' => array(
+ 'entity_type',
+ ),
+ 'bundle' => array(
+ 'bundle',
+ ),
+ 'deleted' => array(
+ 'deleted',
+ ),
+ 'entity_id' => array(
+ 'entity_id',
+ ),
+ 'revision_id' => array(
+ 'revision_id',
+ ),
+ 'language' => array(
+ 'language',
+ ),
+ 'field_reference_target_id' => array(
+ 'field_reference_target_id',
+ ),
+ ),
+ 'mysql_character_set' => 'utf8',
+));
+
+$connection->insert('field_revision_field_reference')
+->fields(array(
+ 'entity_type',
+ 'bundle',
+ 'deleted',
+ 'entity_id',
+ 'revision_id',
+ 'language',
+ 'delta',
+ 'field_reference_target_id',
+))
+->values(array(
+ 'entity_type' => 'node',
+ 'bundle' => 'article',
+ 'deleted' => '0',
+ 'entity_id' => '2',
+ 'revision_id' => '2',
+ 'language' => 'und',
+ 'delta' => '0',
+ 'field_reference_target_id' => '5',
+))
+->values(array(
+ 'entity_type' => 'node',
+ 'bundle' => 'article',
+ 'deleted' => '0',
+ 'entity_id' => '3',
+ 'revision_id' => '3',
+ 'language' => 'und',
+ 'delta' => '0',
+ 'field_reference_target_id' => '4',
+))
+->values(array(
+ 'entity_type' => 'node',
+ 'bundle' => 'article',
+ 'deleted' => '0',
+ 'entity_id' => '4',
+ 'revision_id' => '4',
+ 'language' => 'und',
+ 'delta' => '0',
+ 'field_reference_target_id' => '3',
+))
+->values(array(
+ 'entity_type' => 'node',
+ 'bundle' => 'article',
+ 'deleted' => '0',
+ 'entity_id' => '5',
+ 'revision_id' => '5',
+ 'language' => 'und',
+ 'delta' => '0',
+ 'field_reference_target_id' => '2',
+))
+->execute();
+
+$connection->schema()->createTable('field_revision_field_reference_2', array(
+ 'fields' => array(
+ 'entity_type' => array(
+ 'type' => 'varchar',
+ 'not null' => TRUE,
+ 'length' => '128',
+ 'default' => '',
+ ),
+ 'bundle' => array(
+ 'type' => 'varchar',
+ 'not null' => TRUE,
+ 'length' => '128',
+ 'default' => '',
+ ),
+ 'deleted' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'size' => 'tiny',
+ 'default' => '0',
+ ),
+ 'entity_id' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'size' => 'normal',
+ 'unsigned' => TRUE,
+ ),
+ 'revision_id' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'size' => 'normal',
+ 'unsigned' => TRUE,
+ ),
+ 'language' => array(
+ 'type' => 'varchar',
+ 'not null' => TRUE,
+ 'length' => '32',
+ 'default' => '',
+ ),
+ 'delta' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'size' => 'normal',
+ 'unsigned' => TRUE,
+ ),
+ 'field_reference_2_target_id' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'size' => 'normal',
+ 'unsigned' => TRUE,
+ ),
+ ),
+ 'primary key' => array(
+ 'entity_type',
+ 'entity_id',
+ 'revision_id',
+ 'deleted',
+ 'delta',
+ 'language',
+ ),
+ 'indexes' => array(
+ 'entity_type' => array(
+ 'entity_type',
+ ),
+ 'bundle' => array(
+ 'bundle',
+ ),
+ 'deleted' => array(
+ 'deleted',
+ ),
+ 'entity_id' => array(
+ 'entity_id',
+ ),
+ 'revision_id' => array(
+ 'revision_id',
+ ),
+ 'language' => array(
+ 'language',
+ ),
+ 'field_reference_2_target_id' => array(
+ 'field_reference_2_target_id',
+ ),
+ ),
+ 'mysql_character_set' => 'utf8',
+));
+
+$connection->insert('field_revision_field_reference_2')
+->fields(array(
+ 'entity_type',
+ 'bundle',
+ 'deleted',
+ 'entity_id',
+ 'revision_id',
+ 'language',
+ 'delta',
+ 'field_reference_2_target_id',
+))
+->values(array(
+ 'entity_type' => 'node',
+ 'bundle' => 'article',
+ 'deleted' => '0',
+ 'entity_id' => '2',
+ 'revision_id' => '2',
+ 'language' => 'und',
+ 'delta' => '0',
+ 'field_reference_2_target_id' => '5',
+))
+->values(array(
+ 'entity_type' => 'node',
+ 'bundle' => 'article',
+ 'deleted' => '0',
+ 'entity_id' => '3',
+ 'revision_id' => '3',
+ 'language' => 'und',
+ 'delta' => '0',
+ 'field_reference_2_target_id' => '4',
+))
+->values(array(
+ 'entity_type' => 'node',
+ 'bundle' => 'article',
+ 'deleted' => '0',
+ 'entity_id' => '4',
+ 'revision_id' => '4',
+ 'language' => 'und',
+ 'delta' => '0',
+ 'field_reference_2_target_id' => '3',
+))
+->values(array(
+ 'entity_type' => 'node',
+ 'bundle' => 'article',
+ 'deleted' => '0',
+ 'entity_id' => '5',
+ 'revision_id' => '5',
+ 'language' => 'und',
+ 'delta' => '0',
+ 'field_reference_2_target_id' => '2',
+))
+->execute();
+
$connection->schema()->createTable('field_revision_field_tags', array(
'fields' => array(
'entity_type' => array(
diff --git a/core/modules/migrate_drupal/tests/src/Kernel/d6/FollowUpMigrationsTest.php b/core/modules/migrate_drupal/tests/src/Kernel/d6/FollowUpMigrationsTest.php
new file mode 100644
index 0000000..e02254a
--- /dev/null
+++ b/core/modules/migrate_drupal/tests/src/Kernel/d6/FollowUpMigrationsTest.php
@@ -0,0 +1,78 @@
+<?php
+
+namespace Drupal\Tests\migrate_drupal\Kernel\d6;
+
+use Drupal\node\Entity\Node;
+use Drupal\Tests\node\Kernel\Migrate\d6\MigrateNodeTestBase;
+
+/**
+ * Tests follow-up migrations.
+ *
+ * @group migrate_drupal
+ */
+class FollowUpMigrationsTest extends MigrateNodeTestBase {
+
+ /**
+ * {@inheritdoc}
+ */
+ public static $modules = [
+ 'content_translation',
+ 'language',
+ 'menu_ui',
+ ];
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $this->executeMigrations([
+ 'language',
+ 'd6_language_content_settings',
+ 'd6_node',
+ 'd6_node_translation',
+ ]);
+ }
+
+ /**
+ * Test entity reference translations.
+ */
+ public function testEntityReferenceTranslations() {
+ // Test the entity reference field before the follow-up migrations.
+ $node = Node::load(10);
+ $this->assertSame('13', $node->get('field_reference')->target_id);
+ $this->assertSame('13', $node->get('field_reference_2')->target_id);
+ $translation = $node->getTranslation('fr');
+ $this->assertSame('20', $translation->get('field_reference')->target_id);
+ $this->assertSame('20', $translation->get('field_reference_2')->target_id);
+
+ $node = Node::load(12)->getTranslation('en');
+ $this->assertSame('10', $node->get('field_reference')->target_id);
+ $this->assertSame('10', $node->get('field_reference_2')->target_id);
+ $translation = $node->getTranslation('fr');
+ $this->assertSame('11', $translation->get('field_reference')->target_id);
+ $this->assertSame('11', $translation->get('field_reference_2')->target_id);
+
+ // Run the follow-up migrations.
+ $migration_plugin_manager = $this->container->get('plugin.manager.migration');
+ $migration_plugin_manager->clearCachedDefinitions();
+ $follow_up_migrations = $migration_plugin_manager->createInstances('d6_entity_reference_translation');
+ $this->executeMigrations(array_keys($follow_up_migrations));
+
+ // Test the entity reference field after the follow-up migrations.
+ $node = Node::load(10);
+ $this->assertSame('12', $node->get('field_reference')->target_id);
+ $this->assertSame('12', $node->get('field_reference_2')->target_id);
+ $translation = $node->getTranslation('fr');
+ $this->assertSame('12', $translation->get('field_reference')->target_id);
+ $this->assertSame('12', $translation->get('field_reference_2')->target_id);
+
+ $node = Node::load(12)->getTranslation('en');
+ $this->assertSame('10', $node->get('field_reference')->target_id);
+ $this->assertSame('10', $node->get('field_reference_2')->target_id);
+ $translation = $node->getTranslation('fr');
+ $this->assertSame('10', $translation->get('field_reference')->target_id);
+ $this->assertSame('10', $translation->get('field_reference_2')->target_id);
+ }
+
+}
diff --git a/core/modules/migrate_drupal/tests/src/Kernel/d7/FollowUpMigrationsTest.php b/core/modules/migrate_drupal/tests/src/Kernel/d7/FollowUpMigrationsTest.php
new file mode 100644
index 0000000..9684193
--- /dev/null
+++ b/core/modules/migrate_drupal/tests/src/Kernel/d7/FollowUpMigrationsTest.php
@@ -0,0 +1,105 @@
+<?php
+
+namespace Drupal\Tests\migrate_drupal\Kernel\d7;
+
+use Drupal\node\Entity\Node;
+use Drupal\Tests\file\Kernel\Migrate\d7\FileMigrationSetupTrait;
+
+/**
+ * Tests follow-up migrations.
+ *
+ * @group migrate_drupal
+ */
+class FollowUpMigrationsTest extends MigrateDrupal7TestBase {
+
+ use FileMigrationSetupTrait;
+
+ /**
+ * {@inheritdoc}
+ */
+ public static $modules = [
+ 'content_translation',
+ 'comment',
+ 'datetime',
+ 'file',
+ 'image',
+ 'language',
+ 'link',
+ 'menu_ui',
+ 'node',
+ 'taxonomy',
+ 'telephone',
+ 'text',
+ ];
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+
+ $this->fileMigrationSetup();
+
+ $this->installEntitySchema('node');
+ $this->installEntitySchema('comment');
+ $this->installEntitySchema('taxonomy_term');
+ $this->installConfig(static::$modules);
+ $this->installSchema('node', ['node_access']);
+
+ $this->executeMigrations([
+ 'language',
+ 'd7_user_role',
+ 'd7_user',
+ 'd7_node_type',
+ 'd7_language_content_settings',
+ 'd7_comment_type',
+ 'd7_taxonomy_vocabulary',
+ 'd7_field',
+ 'd7_field_instance',
+ 'd7_node',
+ 'd7_node_translation',
+ ]);
+ }
+
+ /**
+ * Test entity reference translations.
+ */
+ public function testEntityReferenceTranslations() {
+ // Test the entity reference field before the follow-up migrations.
+ $node = Node::load(2);
+ $this->assertSame('5', $node->get('field_reference')->target_id);
+ $this->assertSame('5', $node->get('field_reference_2')->target_id);
+ $translation = $node->getTranslation('is');
+ $this->assertSame('4', $translation->get('field_reference')->target_id);
+ $this->assertSame('4', $translation->get('field_reference_2')->target_id);
+
+ $node = Node::load(4);
+ $this->assertSame('3', $node->get('field_reference')->target_id);
+ $this->assertSame('3', $node->get('field_reference_2')->target_id);
+ $translation = $node->getTranslation('en');
+ $this->assertSame('2', $translation->get('field_reference')->target_id);
+ $this->assertSame('2', $translation->get('field_reference_2')->target_id);
+
+ // Run the follow-up migrations.
+ $migration_plugin_manager = $this->container->get('plugin.manager.migration');
+ $migration_plugin_manager->clearCachedDefinitions();
+ $follow_up_migrations = $migration_plugin_manager->createInstances('d7_entity_reference_translation');
+ $this->executeMigrations(array_keys($follow_up_migrations));
+
+ // Test the entity reference field after the follow-up migrations.
+ $node = Node::load(2);
+ $this->assertSame('4', $node->get('field_reference')->target_id);
+ $this->assertSame('4', $node->get('field_reference_2')->target_id);
+ $translation = $node->getTranslation('is');
+ $this->assertSame('4', $translation->get('field_reference')->target_id);
+ $this->assertSame('4', $translation->get('field_reference_2')->target_id);
+
+ $node = Node::load(4);
+ $this->assertSame('2', $node->get('field_reference')->target_id);
+ $this->assertSame('2', $node->get('field_reference_2')->target_id);
+ $translation = $node->getTranslation('en');
+ $this->assertSame('2', $translation->get('field_reference')->target_id);
+ $this->assertSame('2', $translation->get('field_reference_2')->target_id);
+ }
+
+}