diff --git a/core/modules/migrate_drupal/src/MigrationState.php b/core/modules/migrate_drupal/src/MigrationState.php index 922324c473..3dbe4ad11c 100644 --- a/core/modules/migrate_drupal/src/MigrationState.php +++ b/core/modules/migrate_drupal/src/MigrationState.php @@ -61,6 +61,7 @@ * : , * * Examples: + * * @code * finished: * 6: @@ -291,22 +292,28 @@ public function getMigrationStates() { */ protected function buildUpgradeState($version, array $source_system_data, array $migrations) { $source_destinations = $this->getSourceDestinations($version, $migrations); - $by_source = $this->getMigrationStatesBySource($version); + $declared_by_source = $this->getMigrationStatesBySource($version); + + // Remove core profiles from the system data. + foreach (['standard', 'minimal'] as $profile) { + unset($source_system_data['module'][$profile]); + } + $upgrade_state = []; // Loop through every source module that is enabled on the source site. foreach ($source_system_data['module'] as $module) { $source_module = $module['name']; if ($module['status']) { - // Set the defaults to display. + // Set the defaults. $destination_modules = []; $migration_state = static::NOT_FINISHED; // If there is a declared state for this source module, check the // actual migrations to decide the final state. - if (isset($by_source[$source_module])) { + if (isset($declared_by_source[$source_module])) { // Get the destination modules for this source module. $destination_modules = isset($source_destinations[$source_module]) ? $source_destinations[$source_module] : []; - foreach ($by_source[$source_module] as $destination_module) { + foreach ($declared_by_source[$source_module] as $destination_module) { // Some field plugins use a destination_module of 'core'. if ($destination_module === 'core') { $migration_state = static::FINISHED; @@ -314,19 +321,19 @@ protected function buildUpgradeState($version, array $source_system_data, array } // Check the destination site system info for the state of the // migrations for this source_module. - if (isset($by_source[$source_module])) { + if (isset($declared_by_source[$source_module])) { // If migrations and no declaration then it is not finished. - if (empty($by_source[$source_module])) { + if (empty($declared_by_source[$source_module])) { $migration_state = static::NOT_FINISHED; continue; } // If 'not_finished' declared then it is not finished. - if (in_array('not_finished', $by_source[$source_module])) { + if (in_array('not_finished', $declared_by_source[$source_module])) { $migration_state = static::NOT_FINISHED; continue; } // If 'finished' declared then it is finished. - if (in_array('finished', $by_source[$source_module])) { + if (in_array('finished', $declared_by_source[$source_module])) { $migration_state = static::FINISHED; } } @@ -337,6 +344,15 @@ protected function buildUpgradeState($version, array $source_system_data, array if (in_array($source_module, $this->noUpgradePaths[$version])) { $migration_state = static::FINISHED; $destination_modules = ['core']; + continue; + } + else { + // This source module does not have an entry in any + // migrate_drupal.yml. Determine the migration status based on the + // migrations alone and trigger an error. + // todo: trigger an error. + $return = $this->buildForm($source_module, $version, $source_system_data, $source_destinations); + list($migration_state, $destination_modules) = $return; } } $destination_modules = array_unique($destination_modules); @@ -445,4 +461,36 @@ protected function getMigrationStatesBySource($version) { return $by_source; } + /** + * @return mixed + */ + protected function buildForm($src, $version, $source_system_data, $table_data) { + + // Add source_module and destination_module for modules that do not need an + // upgrade path and are enabled on the source site. + foreach ($this->noUpgradePaths[$version] as $extension) { + if (isset($source_system_data['module'][$extension]) && $source_system_data['module'][$extension]['status']) { + $table_data[$extension]['core'][$extension] = $extension; + } + } + + // Sort the table by source module names and within that destination + // module names. + ksort($table_data); + foreach ($table_data as $source_module => $destination_module_info) { + ksort($table_data[$source_module]); + } + + $unmigrated_source_modules = array_diff_key($source_system_data['module'], $table_data); + if (array_key_exists($src, $unmigrated_source_modules)) { + $state = static::NOT_FINISHED; + return [$state, []]; + } + if (array_key_exists($src, $table_data)) { + $state = static::FINISHED; + return [$state, $table_data[$src]]; + } + + } + } diff --git a/core/modules/migrate_drupal_ui/src/Form/ReviewForm.php b/core/modules/migrate_drupal_ui/src/Form/ReviewForm.php index 6982dbe9e6..8a8ec29372 100644 --- a/core/modules/migrate_drupal_ui/src/Form/ReviewForm.php +++ b/core/modules/migrate_drupal_ui/src/Form/ReviewForm.php @@ -127,11 +127,6 @@ public function buildForm(array $form, FormStateInterface $form_state) { // Fetch the source system data at the first opportunity. $system_data = $this->store->get('system_data'); - // Remove core profiles from the system data. - foreach (['standard', 'minimal'] as $profile) { - unset($system_data['module'][$profile]); - } - // If data is missing or this is the wrong step, start over. if (!$version || !$this->migrations || !$system_data || ($this->store->get('step') != 'review')) {