diff --git a/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php index c04712e..04a66a9 100644 --- a/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php +++ b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php @@ -751,12 +751,7 @@ public function buildOverviewForm(array $form, FormStateInterface $form_state) { * The current state of the form. */ public function submitOverviewForm(array &$form, FormStateInterface $form_state) { - switch ($form_state->getValue('upgrade_option')) { - // @todo Add back support for rollbacks and incremental migrations. - default: - $form_state->setValue('step', 'credentials'); - break; - } + $form_state->setValue('step', 'credentials'); $form_state->setRebuild(); } @@ -873,48 +868,22 @@ public function validateCredentialForm(array &$form, FormStateInterface $form_st // Retrieve the database driver from the form, use reflection to get the // namespace, and then construct a valid database array the same as in // settings.php. - if ($driver = $form_state->getValue('driver')) { - $drivers = $this->getDatabaseTypes(); - $reflection = new \ReflectionClass($drivers[$driver]); - $install_namespace = $reflection->getNamespaceName(); + $driver = $form_state->getValue('driver'); + $drivers = $this->getDatabaseTypes(); + $reflection = new \ReflectionClass($drivers[$driver]); + $install_namespace = $reflection->getNamespaceName(); - $database = $form_state->getValue($driver); - // Cut the trailing \Install from namespace. - $database['namespace'] = substr($install_namespace, 0, strrpos($install_namespace, '\\')); - $database['driver'] = $driver; + $database = $form_state->getValue($driver); + // Cut the trailing \Install from namespace. + $database['namespace'] = substr($install_namespace, 0, strrpos($install_namespace, '\\')); + $database['driver'] = $driver; - // Validate the driver settings and just end here if we have any issues. - if ($errors = $drivers[$driver]->validateDatabaseSettings($database)) { - foreach ($errors as $name => $message) { - $form_state->setErrorByName($name, $message); - } - return; - } - } - else { - $database = []; - // Migration templates that had matching tags for the source Drupal - // version where converted to migration entities. Find one of those - // migrations to be able to look up the matching database credentials - // from state. - $definitions = $this->pluginManager->getDefinitions(); - foreach ($definitions as $id => $definition) { - /** @var \Drupal\migrate\Plugin\MigrationInterface $migration */ - $migration = $this->pluginManager->createInstance($id); - $is_drupal_migration = FALSE; - foreach ($migration->get('migration_tags') as $migration_tag) { - if (substr($migration_tag, 0, 7) === 'Drupal ') { - $is_drupal_migration = TRUE; - break; - } - } - if ($is_drupal_migration) { - $source = $migration->get('source'); - if ($database = $this->state->get($source['database_state_key'])['database']) { - break; - } - } + // Validate the driver settings and just end here if we have any issues. + if ($errors = $drivers[$driver]->validateDatabaseSettings($database)) { + foreach ($errors as $name => $message) { + $form_state->setErrorByName($name, $message); } + return; } try { @@ -990,92 +959,89 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); $form['actions']['submit']['#submit'] = ['::submitConfirmForm']; - // @todo Add back support for rollbacks. - if (TRUE) { - $form['actions']['submit']['#value'] = $this->t('Perform upgrade'); + $form['actions']['submit']['#value'] = $this->t('Perform upgrade'); - $table_data = []; - $system_data = []; - foreach ($form_state->get('migrations') as $migration_id => $migration_label) { - // Fetch the system data at the first opportunity. - if (empty($system_data)) { - $system_data = $form_state->get('system_data'); - } - - // Handle derivatives. - list($migration_id,) = explode(':', $migration_id, 2); - $source_module = $this->moduleUpgradePaths[$migration_id]['source_module']; - $destination_module = $this->moduleUpgradePaths[$migration_id]['destination_module']; - $table_data[$source_module][$destination_module][$migration_id] = $migration_label; - } - // 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]); + $table_data = []; + $system_data = []; + foreach ($form_state->get('migrations') as $migration_id => $migration_label) { + // Fetch the system data at the first opportunity. + if (empty($system_data)) { + $system_data = $form_state->get('system_data'); } - $unmigrated_source_modules = array_diff_key($system_data['module'], $table_data); - // Missing migrations. - $form['missing_module_list_title'] = [ - '#type' => 'item', - '#title' => $this->t('Missing upgrade paths'), - '#description' => $this->t('The following items will not be upgraded. For more information see Upgrading from Drupal 6 or 7 to Drupal 8.', array(':migrate' => 'https://www.drupal.org/upgrade/migrate')), - ]; - $form['missing_module_list'] = [ - '#type' => 'table', - '#header' => [ - $this->t('Source'), - $this->t('Destination'), - ], - ]; - $missing_count = 0; - ksort($unmigrated_source_modules); - foreach ($unmigrated_source_modules as $source_module => $module_data) { - if ($module_data['status']) { - $missing_count++; - $form['missing_module_list'][$source_module] = [ - 'source_module' => ['#plain_text' => $source_module], - 'destination_module' => ['#plain_text' => 'Missing'], - ]; - } + // Handle derivatives. + list($migration_id,) = explode(':', $migration_id, 2); + $source_module = $this->moduleUpgradePaths[$migration_id]['source_module']; + $destination_module = $this->moduleUpgradePaths[$migration_id]['destination_module']; + $table_data[$source_module][$destination_module][$migration_id] = $migration_label; + } + // 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($system_data['module'], $table_data); + + // Missing migrations. + $form['missing_module_list_title'] = [ + '#type' => 'item', + '#title' => $this->t('Missing upgrade paths'), + '#description' => $this->t('The following items will not be upgraded. For more information see Upgrading from Drupal 6 or 7 to Drupal 8.', array(':migrate' => 'https://www.drupal.org/upgrade/migrate')), + ]; + $form['missing_module_list'] = [ + '#type' => 'table', + '#header' => [ + $this->t('Source'), + $this->t('Destination'), + ], + ]; + $missing_count = 0; + ksort($unmigrated_source_modules); + foreach ($unmigrated_source_modules as $source_module => $module_data) { + if ($module_data['status']) { + $missing_count++; + $form['missing_module_list'][$source_module] = [ + 'source_module' => ['#plain_text' => $source_module], + 'destination_module' => ['#plain_text' => 'Missing'], + ]; } - // Available migrations. - $form['available_module_list'] = [ - '#tree' => TRUE, - '#type' => 'details', - '#title' => $this->t('Available upgrade paths'), - ]; + } + // Available migrations. + $form['available_module_list'] = [ + '#tree' => TRUE, + '#type' => 'details', + '#title' => $this->t('Available upgrade paths'), + ]; - $form['available_module_list']['module_list'] = [ - '#type' => 'table', - '#header' => [ - $this->t('Source'), - $this->t('Destination'), - ], - ]; + $form['available_module_list']['module_list'] = [ + '#type' => 'table', + '#header' => [ + $this->t('Source'), + $this->t('Destination'), + ], + ]; - $available_count = 0; - foreach ($table_data as $source_module => $destination_module_info) { - $available_count++; - $destination_details = []; - foreach ($destination_module_info as $destination_module => $migration_ids) { - $destination_details[$destination_module] = [ - '#type' => 'item', - '#plain_text' => $destination_module, - ]; - } - $form['available_module_list']['module_list'][$source_module] = [ - 'source_module' => ['#plain_text' => $source_module], - 'destination_module' => $destination_details, + $available_count = 0; + foreach ($table_data as $source_module => $destination_module_info) { + $available_count++; + $destination_details = []; + foreach ($destination_module_info as $destination_module => $migration_ids) { + $destination_details[$destination_module] = [ + '#type' => 'item', + '#plain_text' => $destination_module, ]; } - $form['counts'] = [ - '#type' => 'item', - '#title' => '