diff --git a/core/modules/migrate/src/Plugin/MigrationPluginManager.php b/core/modules/migrate/src/Plugin/MigrationPluginManager.php index 910124d..71f50a1 100644 --- a/core/modules/migrate/src/Plugin/MigrationPluginManager.php +++ b/core/modules/migrate/src/Plugin/MigrationPluginManager.php @@ -162,7 +162,6 @@ public function buildDependencyMigration(array $migrations, array $dynamic_ids) // current migration. $dependency_graph = []; $required_dependency_graph = []; - $different = FALSE; foreach ($migrations as $migration) { /** @var \Drupal\migrate\Entity\MigrationInterface $migration */ $id = $migration->id(); @@ -180,13 +179,12 @@ public function buildDependencyMigration(array $migrations, array $dynamic_ids) } if (isset($migration_dependencies['optional'])) { foreach ($migration_dependencies['optional'] as $dependency) { - $different = TRUE; $this->addDependency($dependency_graph, $id, $dependency, $dynamic_ids); } } } $dependency_graph = (new Graph($dependency_graph))->searchAndSort(); - if ($different) { + if (!empty($migration_dependencies['optional'])) { $required_dependency_graph = (new Graph($required_dependency_graph))->searchAndSort(); } else { diff --git a/core/modules/migrate/tests/src/Unit/destination/ConfigTest.php b/core/modules/migrate/tests/src/Unit/destination/ConfigTest.php index 88c087b..b3c8b7a 100644 --- a/core/modules/migrate/tests/src/Unit/destination/ConfigTest.php +++ b/core/modules/migrate/tests/src/Unit/destination/ConfigTest.php @@ -73,7 +73,7 @@ public function testLanguageImport() { $source = array( 'langcode' => 'mi', ); - $migration = $this->getMockBuilder('Drupal\migrate\Entity\Migration') + $migration = $this->getMockBuilder('Drupal\migrate\Entity\MigrationInterface') ->disableOriginalConstructor() ->getMock(); $config = $this->getMockBuilder('Drupal\Core\Config\Config') diff --git a/core/modules/migrate_drupal/migrate_drupal.module b/core/modules/migrate_drupal/migrate_drupal.module index f8ddb78..d31feed 100644 --- a/core/modules/migrate_drupal/migrate_drupal.module +++ b/core/modules/migrate_drupal/migrate_drupal.module @@ -6,6 +6,7 @@ */ use Drupal\Core\Routing\RouteMatchInterface; +use Drupal\migrate\Exception\RequirementsException; use Drupal\migrate\MigrateExecutable; use Drupal\migrate\MigrateMessage; use Drupal\migrate\Plugin\Migration; @@ -41,9 +42,11 @@ function migrate_drupal_migration_plugins_alter(&$definitions) { ], ]; $vocabulary_migration = new Migration([], uniqid(), $vocabulary_migration_definition); - $executable = new MigrateExecutable($vocabulary_migration, new MigrateMessage()); - $process = ['vid' => $definitions['d6_taxonomy_vocabulary']['process']['vid']]; + try { + $vocabulary_migration->checkRequirements(); + $executable = new MigrateExecutable($vocabulary_migration, new MigrateMessage()); + $process = ['vid' => $definitions['d6_taxonomy_vocabulary']['process']['vid']]; foreach ($vocabulary_migration->getSourcePlugin() as $row) { $executable->processRow($row, $process); $source_vid = $row->getSourceProperty('vid'); @@ -55,8 +58,11 @@ function migrate_drupal_migration_plugins_alter(&$definitions) { } } } - catch (\Exception $e) { - + catch (RequirementsException $e) { + // This code currently runs whenever the definitions are being loaded and + // if you have a Drupal 7 source site then the requirements will not be + // met for the d6_taxonomy_vocabulary migration. } + } }