diff --git a/core/modules/migrate/src/Entity/Migration.php b/core/modules/migrate/src/Entity/Migration.php index 0d7e3c81f606..094713d1d16e 100644 --- a/core/modules/migrate/src/Entity/Migration.php +++ b/core/modules/migrate/src/Entity/Migration.php @@ -585,8 +585,11 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem parent::calculateDependencies(); $this->calculatePluginDependencies($this->getSourcePlugin()); $this->calculatePluginDependencies($this->getDestinationPlugin()); - // Add dependencies on required migration dependencies. - foreach ($this->getMigrationDependencies()['required'] as $dependency) { + + // Add hard dependencies on required migrations. + $dependencies = $this->getEntityManager()->getStorage($this->entityTypeId) + ->getVariantIds($this->getMigrationDependencies()['required']); + foreach ($dependencies as $dependency) { $this->addDependency('config', $this->getEntityType()->getConfigPrefix() . '.' . $dependency); } diff --git a/core/modules/migrate/src/MigrationStorage.php b/core/modules/migrate/src/MigrationStorage.php index 93c371bd3224..e43496e3649d 100644 --- a/core/modules/migrate/src/MigrationStorage.php +++ b/core/modules/migrate/src/MigrationStorage.php @@ -92,7 +92,7 @@ class MigrationStorage extends ConfigEntityStorage implements MigrateBuildDepend * @return string[] * The expanded list of IDs. */ - protected function getVariantIds(array $ids) { + public function getVariantIds(array $ids) { // Re-index the array numerically, since we need to limit the loop by size. $ids = array_values($ids); diff --git a/core/modules/migrate/tests/src/Kernel/Entity/MigrationTest.php b/core/modules/migrate/tests/src/Kernel/Entity/MigrationTest.php new file mode 100644 index 000000000000..fd37ac44ce16 --- /dev/null +++ b/core/modules/migrate/tests/src/Kernel/Entity/MigrationTest.php @@ -0,0 +1,76 @@ + 'd6_node', + 'd6_node__page' => 'd6_node', + 'd6_variables' => 'd6_variables', + ]; + + foreach ($fixture_migrations as $id => $template) { + $values = [ + 'id' => $id, + 'template' => $template, + 'source' => [ + 'plugin' => 'empty', + ], + 'destination' => [ + 'plugin' => 'null', + ], + 'migration_tags' => [] + ]; + Migration::create($values)->save(); + } + + $values = [ + 'migration_dependencies' => [ + 'required' => [ + 'd6_node:*', + 'd6_variables' + ] + ], + 'source' => [ + 'plugin' => 'empty', + ], + 'destination' => [ + 'plugin' => 'null', + ], + ]; + + $migration = new Migration($values, 'migration'); + $expected = [ + 'migrate.migration.d6_node__article', + 'migrate.migration.d6_node__page', + 'migrate.migration.d6_variables' + ]; + $migration->calculateDependencies(); + $this->assertEquals($expected, $migration->getDependencies()['config']); + } + +} diff --git a/core/modules/node/migration_templates/d6_node_revision.yml b/core/modules/node/migration_templates/d6_node_revision.yml index c22e62a856de..e7f3b544b214 100644 --- a/core/modules/node/migration_templates/d6_node_revision.yml +++ b/core/modules/node/migration_templates/d6_node_revision.yml @@ -39,6 +39,3 @@ process: destination: plugin: entity_revision:node -migration_dependencies: - required: - - d6_node:* diff --git a/core/modules/node/src/Plugin/migrate/builder/d6/Node.php b/core/modules/node/src/Plugin/migrate/builder/d6/Node.php index ca978426bfa3..99f8d45a6b65 100644 --- a/core/modules/node/src/Plugin/migrate/builder/d6/Node.php +++ b/core/modules/node/src/Plugin/migrate/builder/d6/Node.php @@ -41,9 +41,17 @@ class Node extends CckBuilder { $node_type = $row->getSourceProperty('type'); $values = $template; $values['id'] = $template['id'] . '__' . $node_type; + $label = $template['label']; $values['label'] = $this->t("@label (@type)", ['@label' => $label, '@type' => $node_type]); $values['source']['node_type'] = $node_type; + + // If this migration is based on the d6_node_revision template, it should + // explicitly depend on the corresponding d6_node variant. + if ($template['id'] == 'd6_node_revision') { + $values['migration_dependencies']['required'][] = 'd6_node__' . $node_type; + } + $migration = Migration::create($values); if (isset($fields[$node_type])) {