diff --git a/core/modules/migrate/config/schema/migrate.schema.yml b/core/modules/migrate/config/schema/migrate.schema.yml index b01bd4550c1ce16b4ae9b3a8130201a2ae5df4ff..fe4ea1a51f8b74f59b49100bd9102872aa67b71e 100644 --- a/core/modules/migrate/config/schema/migrate.schema.yml +++ b/core/modules/migrate/config/schema/migrate.schema.yml @@ -1,7 +1,7 @@ # Schema for the configuration files of the Migrate module. migrate.migration.*: - type: mapping + type: config_entity label: 'Migration' mapping: id: diff --git a/core/modules/migrate/src/Entity/Migration.php b/core/modules/migrate/src/Entity/Migration.php index da71c0be56e3aa701b1faf9fd74d1ebb60a2a848..8c9388d36f670d9cbfb31afb5633d93619bf3f1e 100644 --- a/core/modules/migrate/src/Entity/Migration.php +++ b/core/modules/migrate/src/Entity/Migration.php @@ -326,15 +326,7 @@ public function checkRequirements() { $required_migrations = \Drupal::entityManager()->getStorage('migration')->loadMultiple($this->requirements); // Check if the dependencies are in good shape. foreach ($required_migrations as $required_migration) { - // If the dependent source migration has no IDs then no mappings can - // be recorded thus it is impossible to see whether the migration ran. - if (!$required_migration->getSourcePlugin()->getIds()) { - return FALSE; - } - - // If the dependent migration has not processed any record, it means the - // dependency requirements are not met. - if (!$required_migration->getIdMap()->processedCount()) { + if (!$required_migration->isComplete()) { return FALSE; } } @@ -346,4 +338,27 @@ public function checkRequirements() { return TRUE; } + /** + * {@inheritdoc} + */ + public function setMigrationResult($result) { + $migrate_result_store = \Drupal::keyValue('migrate_result'); + $migrate_result_store->set($this->id(), $result); + } + + /** + * {@inheritdoc} + */ + public function getMigrationResult() { + $migrate_result_store = \Drupal::keyValue('migrate_result'); + return $migrate_result_store->get($this->id(), static::RESULT_INCOMPLETE); + } + + /** + * {@inheritdoc} + */ + public function isComplete() { + return $this->getMigrationResult() === static::RESULT_COMPLETED; + } + } diff --git a/core/modules/migrate/src/Entity/MigrationInterface.php b/core/modules/migrate/src/Entity/MigrationInterface.php index 141bdf1eef950446263bbacc2199fe112314a477..415099389c62d3ad0fbcfb2a4039268a7959035e 100644 --- a/core/modules/migrate/src/Entity/MigrationInterface.php +++ b/core/modules/migrate/src/Entity/MigrationInterface.php @@ -102,4 +102,28 @@ public function getHighwater(); */ public function saveHighwater($highwater); + /** + * Check if this migration is complete. + * + * @return bool + * TRUE if this migration is complete otherwise FALSE. + */ + public function isComplete(); + + /** + * Set the migration result. + * + * @param int $result + * One of the RESULT_* constants. + */ + public function setMigrationResult($result); + + /** + * Get the current migration result. + * + * @return int + * The current migration result. Defaults to RESULT_INCOMPLETE. + */ + public function getMigrationResult(); + } diff --git a/core/modules/migrate/src/MigrateExecutable.php b/core/modules/migrate/src/MigrateExecutable.php index 5b9d8bb86850f7f7d17155eba7cae2b0d9f63492..afcc745138e448ca09731c225ba8eabebb522a60 100644 --- a/core/modules/migrate/src/MigrateExecutable.php +++ b/core/modules/migrate/src/MigrateExecutable.php @@ -21,7 +21,7 @@ class MigrateExecutable { /** * The configuration of the migration to do. * - * @var \Drupal\migrate\Entity\MigrationInterface + * @var \Drupal\migrate\Entity\Migration */ protected $migration; @@ -333,6 +333,7 @@ public function import() { */ #$this->progressMessage($return); + $this->migration->setMigrationResult($return); return $return; } diff --git a/core/modules/migrate/src/Tests/MigrateTestBase.php b/core/modules/migrate/src/Tests/MigrateTestBase.php index 39a23e2523bb19f339f3f482c85d4f66ef498f90..1ed738fe7ffea94eab79f93c9056ee2974a30611 100644 --- a/core/modules/migrate/src/Tests/MigrateTestBase.php +++ b/core/modules/migrate/src/Tests/MigrateTestBase.php @@ -116,6 +116,11 @@ protected function prepareIdMappings(array $id_mappings) { $migrations = entity_load_multiple('migration', array_keys($id_mappings)); foreach ($id_mappings as $migration_id => $data) { $migration = $migrations[$migration_id]; + + // @TODO, rename prepareIdMappings() in https://drupal.org/node/2315489 + // which will make the position of this more appropriate. + $migration->setMigrationResult(MigrationInterface::RESULT_COMPLETED); + $id_map = $migration->getIdMap(); $id_map->setMessage($this); $source_ids = $migration->getSourcePlugin()->getIds(); diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_block.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_block.yml index 4c15527b0a75b7838bb7e6d941d068b9ed5c13b3..6d1f3985df758413ca5e7493f5c29d95690f85b3 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_block.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_block.yml @@ -84,6 +84,6 @@ process: destination: plugin: entity:block migration_dependencies: - optional: + required: - d6_menu - d6_custom_block diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_comment.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_comment.yml index 5901c67361580bf6e2d0631d90e03ba625a2f583..4cfea2f491fae51f0995cf9531ef5a95b09ee6de 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_comment.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_comment.yml @@ -48,10 +48,9 @@ process: destination: plugin: entity:comment migration_dependencies: - optional: - - d6_comment_type required: - d6_node + - d6_comment_type - d6_user - d6_comment_entity_display - d6_comment_entity_form_display diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_node.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_node.yml index fcf411aa14aa8b016543c043106bca2a36ab0018..cc210c81d994d2e688a8457ad30e5e2506d3aa69 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_node.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_node.yml @@ -33,8 +33,7 @@ destination: migration_dependencies: required: - d6_node_type + - d6_node_settings - d6_filter_format - optional: - d6_field_instance_widget_settings - d6_field_formatter_settings - - d6_node_settings diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_picture_file.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_picture_file.yml index d142dbb79c4466d167e395801bafa2682978e12c..8e3fd25a6ed6dd4bb9deb2165a525ca835bed402 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_picture_file.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_picture_file.yml @@ -22,3 +22,6 @@ migration_dependencies: # migration as an optional dependency to ensure it runs first. optional: - d6_file +dependencies: + module: + - file diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockTest.php index a22bacb27a295f5f6102538f3870f8f89f42af0c..70d926018553c67451e8ac89e2974f23df5752fa 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockTest.php @@ -52,7 +52,10 @@ public function setUp() { array(array(11), array(2)), array(array(12), array(1)), array(array(13), array(2)), - ) + ), + 'd6_menu' => array( + array(array('menu1'), array('menu')), + ), )); // Set Bartik and Seven as the default public and admin theme. diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateNodeTestBase.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateNodeTestBase.php index e51a2d113909c1bd2a4a229aa226587a945b1500..746023ec38c09abdd4796313661a5f27d52a59da 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateNodeTestBase.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateNodeTestBase.php @@ -8,6 +8,7 @@ namespace Drupal\migrate_drupal\Tests\d6; use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase; +use Drupal\migrate\Entity\MigrationInterface; /** * Base class for Node migration tests. @@ -33,9 +34,24 @@ protected function setUp() { array(array(1), array('filtered_html')), array(array(2), array('full_html')), ), + 'd6_field_instance_widget_settings' => array( + array( + array('page', 'field_test'), + array('node', 'page', 'default', 'test'), + ), + ), + 'd6_field_formatter_settings' => array( + array( + array('page', 'default', 'node', 'field_test'), + array('node', 'page', 'default', 'field_test'), + ), + ), ); $this->prepareIdMappings($id_mappings); + $migration = entity_load('migration', 'd6_node_settings'); + $migration->setMigrationResult(MigrationInterface::RESULT_COMPLETED); + // Create a test node. $node = entity_create('node', array( 'type' => 'story', diff --git a/core/modules/migrate_drupal/src/Tests/dependencies/MigrateDependenciesTest.php b/core/modules/migrate_drupal/src/Tests/dependencies/MigrateDependenciesTest.php index e5168b0ea22c224b8762236514e1d09b88c29472..8d69c64b44c2581b784b226b1c2ca2521e4d3a0f 100644 --- a/core/modules/migrate_drupal/src/Tests/dependencies/MigrateDependenciesTest.php +++ b/core/modules/migrate_drupal/src/Tests/dependencies/MigrateDependenciesTest.php @@ -30,7 +30,18 @@ public function testMigrateDependenciesOrder() { $migrations = entity_load_multiple('migration', $migration_items); $expected_order = array('d6_filter_format', 'd6_node', 'd6_comment'); $this->assertEqual(array_keys($migrations), $expected_order); - $expected_requirements = array('d6_node', 'd6_node_type', 'd6_filter_format', 'd6_user', 'd6_comment_entity_display', 'd6_comment_entity_form_display'); + $expected_requirements = array( + 'd6_node', + 'd6_node_type', + 'd6_node_settings', + 'd6_field_instance_widget_settings', + 'd6_field_formatter_settings', + 'd6_filter_format', + 'd6_user', + 'd6_comment_type', + 'd6_comment_entity_display', + 'd6_comment_entity_form_display', + ); // Migration dependencies for comment include dependencies for node // migration as well. $actual_requirements = $migrations['d6_comment']->get('requirements');