diff --git a/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php index e6365f5..04a66a9 100644 --- a/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php +++ b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php @@ -26,16 +26,6 @@ class MigrateUpgradeForm extends ConfirmFormBase { use MigrationCreationTrait; /** - * If a migration has previously run, perform an incremental migration. - */ - const MIGRATE_UPGRADE_INCREMENTAL = 1; - - /** - * If a migration has previously run, roll it back and start fresh. - */ - const MIGRATE_UPGRADE_ROLLBACK = 2; - - /** * Mapping of known migrations and their source and destination modules. * * @todo https://www.drupal.org/node/2569805 Hardcoding this information is @@ -705,21 +695,13 @@ public function buildOverviewForm(array $form, FormStateInterface $form_state) { $form['#title'] = $this->t('Drupal Upgrade'); if ($date_performed = $this->state->get('migrate_drupal_ui.performed')) { + // @todo Add back support for rollbacks and incremental migrations. $form['upgrade_option_item'] = [ '#type' => 'item', - '#prefix' => $this->t('

An upgrade has already been performed on this site.

'), + '#prefix' => $this->t('An upgrade has already been performed on this site. To perform a new migration, create a clean and empty new install of Drupal 8. Rollbacks and incremental migrations are not yet supported through the user inteface. For more information, see the upgrading handbook.', [':url' => 'https://www.drupal.org/upgrade/migrate']), '#description' => $this->t('

Last upgrade: @date

', ['@date' => $this->dateFormatter->format($date_performed)]), ]; - $form['upgrade_option'] = array( - '#type' => 'radios', - '#title' => $this->t('You have two options:'), - '#default_value' => static::MIGRATE_UPGRADE_INCREMENTAL, - '#options' => [ - static::MIGRATE_UPGRADE_INCREMENTAL => $this->t('Rerun: Import additional configuration and content that was not available when running the upgrade previously.'), - static::MIGRATE_UPGRADE_ROLLBACK => $this->t('Rollback: Remove content and configuration entities (such as fields and node types). Default values of other configuration will not be reverted (such as site name).'), - ], - ); - $validate = ['::validateCredentialForm']; + return $form; } else { $form['info_header'] = [ @@ -769,19 +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')) { - case static::MIGRATE_UPGRADE_INCREMENTAL: - $form_state->setValue('step', 'confirm'); - break; - - case static::MIGRATE_UPGRADE_ROLLBACK: - $form_state->setValue('step', 'confirm'); - break; - - default: $form_state->setValue('step', 'credentials'); - break; - } $form_state->setRebuild(); } @@ -894,15 +864,11 @@ public function buildCredentialForm(array $form, FormStateInterface $form_state) * The current state of the form. */ public function validateCredentialForm(array &$form, FormStateInterface $form_state) { - // Skip if rollback was chosen. - if ($form_state->getValue('upgrade_option') == static::MIGRATE_UPGRADE_ROLLBACK) { - return; - } // 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')) { + $driver = $form_state->getValue('driver'); $drivers = $this->getDatabaseTypes(); $reflection = new \ReflectionClass($drivers[$driver]); $install_namespace = $reflection->getNamespaceName(); @@ -919,32 +885,6 @@ public function validateCredentialForm(array &$form, FormStateInterface $form_st } 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; - } - } - } - } try { $connection = $this->getConnection($database); @@ -1005,7 +945,7 @@ public function submitCredentialForm(array &$form, FormStateInterface $form_stat } /** - * Confirmation form for rollbacks, missing migrations, etc. + * Confirmation form for missing migrations, etc. * * @param array $form * An associative array containing the structure of the form. @@ -1019,14 +959,6 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); $form['actions']['submit']['#submit'] = ['::submitConfirmForm']; - if ($rollback = $form_state->getValue('upgrade_option') == static::MIGRATE_UPGRADE_ROLLBACK) { - $form_state->setStorage(['upgrade_option' => static::MIGRATE_UPGRADE_ROLLBACK]); - $form['rollback'] = [ - '#markup' => $this->t('All previously imported content, as well as configuration such as field definitions, will be removed.'), - ]; - $form['actions']['submit']['#value'] = $this->t('Perform rollback'); - } - else { $form['actions']['submit']['#value'] = $this->t('Perform upgrade'); $table_data = []; @@ -1110,7 +1042,6 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) { '#title' => '', '#weight' => -15, ]; - } return $form; } @@ -1125,45 +1056,7 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) { */ public function submitConfirmForm(array &$form, FormStateInterface $form_state) { $storage = $form_state->getStorage(); - if (isset($storage['upgrade_option']) && $storage['upgrade_option'] == static::MIGRATE_UPGRADE_ROLLBACK) { - $migrations = $this->pluginManager->createInstances([]); - // Assume we want all those tagged 'Drupal %'. - foreach ($migrations as $migration_id => $migration) { - $keep = FALSE; - $tags = $migration->get('migration_tags'); - foreach ($tags as $tag) { - if (strpos($tag, 'Drupal ') === 0) { - $keep = TRUE; - break; - } - } - if (!$keep) { - unset($migrations[$migration_id]); - } - } - // Roll back in reverse order. - $migrations = array_reverse($migrations); - - $batch = [ - 'title' => $this->t('Rolling back upgrade'), - 'progress_message' => '', - 'operations' => [ - [ - [MigrateUpgradeRunBatch::class, 'run'], - [array_keys($migrations), 'rollback', []], - ], - ], - 'finished' => [ - MigrateUpgradeRunBatch::class, - 'finished', - ], - ]; - batch_set($batch); - $form_state->setRedirect('migrate_drupal_ui.upgrade'); - $this->state->delete('migrate_drupal_ui.performed'); - } - else { $migrations = $storage['migrations']; $config['source_base_path'] = $storage['source_base_path']; $batch = [ @@ -1184,7 +1077,6 @@ public function submitConfirmForm(array &$form, FormStateInterface $form_state) $form_state->setRedirect(''); $this->state->set('migrate_drupal_ui.performed', REQUEST_TIME); } - } /** * Returns all supported database driver installer objects. diff --git a/core/modules/migrate_drupal_ui/src/MigrateUpgradeRunBatch.php b/core/modules/migrate_drupal_ui/src/MigrateUpgradeRunBatch.php index 3c30eac..a614d93 100644 --- a/core/modules/migrate_drupal_ui/src/MigrateUpgradeRunBatch.php +++ b/core/modules/migrate_drupal_ui/src/MigrateUpgradeRunBatch.php @@ -64,7 +64,7 @@ class MigrateUpgradeRunBatch { * @param int[] $initial_ids * The full set of migration IDs to import. * @param string $operation - * The operation to perform, 'import' or 'rollback'. + * The operation to perform. Only 'import' is currently supported. * @param array $config * An array of additional configuration from the form. * @param array $context @@ -78,10 +78,6 @@ public static function run($initial_ids, $operation, $config, &$context) { $event_dispatcher->addListener(MigrateEvents::MAP_SAVE, [static::class, 'onMapSave']); $event_dispatcher->addListener(MigrateEvents::IDMAP_MESSAGE, [static::class, 'onIdMapMessage']); } - else { - $event_dispatcher->addListener(MigrateEvents::POST_ROW_DELETE, [static::class, 'onPostRowDelete']); - $event_dispatcher->addListener(MigrateEvents::MAP_DELETE, [static::class, 'onMapDelete']); - } static::$maxExecTime = ini_get('max_execution_time'); if (static::$maxExecTime <= 0) { static::$maxExecTime = 60; @@ -131,9 +127,6 @@ public static function run($initial_ids, $operation, $config, &$context) { if ($operation == 'import') { $migration_status = $executable->import(); } - else { - $migration_status = $executable->rollback(); - } } catch (\Exception $e) { static::logger()->error($e->getMessage()); @@ -149,11 +142,6 @@ public static function run($initial_ids, $operation, $config, &$context) { $context['sandbox']['num_processed'], 'Upgraded @migration (processed 1 item total)', 'Upgraded @migration (processed @num_processed items total)', ['@migration' => $migration_name, '@num_processed' => $context['sandbox']['num_processed']]); } - else { - $message = static::getTranslation()->formatPlural( - $context['sandbox']['num_processed'], 'Rolled back @migration (processed 1 item total)', 'Rolled back @migration (processed @num_processed items total)', - ['@migration' => $migration_name, '@num_processed' => $context['sandbox']['num_processed']]); - } $context['sandbox']['messages'][] = $message; static::logger()->notice($message); $context['sandbox']['num_processed'] = 0; @@ -222,13 +210,6 @@ public static function run($initial_ids, $operation, $config, &$context) { '@max' => $context['sandbox']['max'], ]) . "
\n" . $context['message']; } - else { - $context['message'] = t('Currently rolling back @migration (@current of @max total tasks)', [ - '@migration' => $migration_name, - '@current' => $context['sandbox']['current'], - '@max' => $context['sandbox']['max'], - ]) . "
\n" . $context['message']; - } } } else { @@ -281,9 +262,6 @@ protected static function displayResults($results) { if ($results['operation'] == 'import') { drupal_set_message(static::getTranslation()->formatPlural($successes, 'Completed 1 upgrade task successfully', 'Completed @count upgrade tasks successfully')); } - else { - drupal_set_message(static::getTranslation()->formatPlural($successes, 'Completed 1 rollback task successfully', 'Completed @count rollback tasks successfully')); - } } // If we had failures, log them and show the migration failed. @@ -292,10 +270,6 @@ protected static function displayResults($results) { drupal_set_message(static::getTranslation()->formatPlural($failures, '1 upgrade failed', '@count upgrades failed')); drupal_set_message(t('Upgrade process not completed'), 'error'); } - else { - drupal_set_message(static::getTranslation()->formatPlural($failures, '1 rollback failed', '@count rollbacks failed')); - drupal_set_message(t('Rollback process not completed'), 'error'); - } } else { if ($results['operation'] == 'import') { @@ -303,9 +277,6 @@ protected static function displayResults($results) { // but we didn't have failures so this is fine. drupal_set_message(t('Congratulations, you upgraded Drupal!')); } - else { - drupal_set_message(t('Rollback of the upgrade is complete - you may now start the upgrade process from scratch.')); - } } if (\Drupal::moduleHandler()->moduleExists('dblog')) {