diff --git a/core/modules/migrate/tests/src/Kernel/Plugin/MigrationProvidersExistTest.php b/core/modules/migrate/tests/src/Kernel/Plugin/MigrationProvidersExistTest.php index 19a8b24777..1b4aaa35e3 100644 --- a/core/modules/migrate/tests/src/Kernel/Plugin/MigrationProvidersExistTest.php +++ b/core/modules/migrate/tests/src/Kernel/Plugin/MigrationProvidersExistTest.php @@ -70,11 +70,11 @@ public function testProvidersExist() { public function testFieldProvidersExist() { $expected_mappings = [ 'userreference' => [ - 'source_module' => 'user_reference', + 'source_module' => 'userreference', 'destination_module' => 'core', ], 'nodereference' => [ - 'source_module' => 'node_reference', + 'source_module' => 'nodereference', 'destination_module' => 'core', ], 'optionwidgets' => [ diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php b/core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php index d3205a6029..e8c2dd5e6d 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php @@ -11,7 +11,7 @@ * type_map = { * "nodereference" = "entity_reference", * }, - * source_module = "node_reference", + * source_module = "nodereference", * destination_module = "core", * ) */ diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/field/UserReference.php b/core/modules/migrate_drupal/src/Plugin/migrate/field/UserReference.php index b52b44603c..b42d94cba3 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/field/UserReference.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/field/UserReference.php @@ -11,7 +11,7 @@ * type_map = { * "userreference" = "entity_reference", * }, - * source_module = "user_reference", + * source_module = "userreference", * destination_module = "core", * ) */ diff --git a/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php index 898a8a5568..6ce595cffa 100644 --- a/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php +++ b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php @@ -69,6 +69,54 @@ class MigrateUpgradeForm extends ConfirmFormBase { protected $moduleHandler; /** + * List of modules that do not need an upgrade path. + */ + protected $noUpgradePath = [ + '6' => [ + 'blog', + 'color', + 'date_api', + 'date_timezone', + 'help', + 'i18n', + 'i18nstrings', + 'imageapi', + 'number', + 'openid', + 'php', + 'poll', + 'profile', + 'trigger', + 'tracker', + 'variable', + 'variable_admin', + 'views', + 'views_export', + 'views_ui', + ], + '7' => [ + 'blog', + 'contextual', + 'dashboard', + 'date_api', + 'entity', + 'field_ui', + 'help', + 'openid', + 'overlay', + 'php', + 'poll', + 'profile', + 'simpletest', + 'syslog', + 'trigger', + 'toolbar', + 'views', + 'views_ui', + ], + ]; + + /** * Constructs the MigrateUpgradeForm. * * @param \Drupal\Core\State\StateInterface $state @@ -160,6 +208,9 @@ public function submitForm(array &$form, FormStateInterface $form_state) { public function buildOverviewForm(array $form, FormStateInterface $form_state) { $form['#title'] = $this->t('Upgrade'); + // Add the no upgrade path array to the form state so it can be altered. + $form_state->set('no_upgrade_path', $this->noUpgradePath); + if ($date_performed = $this->state->get('migrate_drupal_ui.performed')) { // @todo Add back support for rollbacks and incremental migrations. // https://www.drupal.org/node/2687843 @@ -269,7 +320,7 @@ public function buildCredentialForm(array $form, FormStateInterface $form_state) '#type' => 'radios', '#default_value' => 7, '#title' => $this->t('Drupal version of the source site'), - '#options' => [6 => $this->t('Drupal 6'), 7 => $this->t('Drupal 7')], + '#options' => ['6' => $this->t('Drupal 6'), '7' => $this->t('Drupal 7')], '#required' => TRUE, ]; @@ -332,7 +383,7 @@ public function buildCredentialForm(array $form, FormStateInterface $form_state) '#description' => $this->t('To import files from your current Drupal site, enter a local file directory containing your site (e.g. /var/www/docroot), or your site address (for example http://example.com).'), '#states' => [ 'visible' => [ - ':input[name="version"]' => ['value' => 6], + ':input[name="version"]' => ['value' => '6'], ], ], ]; @@ -343,7 +394,7 @@ public function buildCredentialForm(array $form, FormStateInterface $form_state) '#description' => $this->t('To import public files from your current Drupal site, enter a local file directory containing your site (e.g. /var/www/docroot), or your site address (for example http://example.com).'), '#states' => [ 'visible' => [ - ':input[name="version"]' => ['value' => 7], + ':input[name="version"]' => ['value' => '7'], ], ], ]; @@ -355,7 +406,7 @@ public function buildCredentialForm(array $form, FormStateInterface $form_state) '#description' => $this->t('To import private files from your current Drupal site, enter a local file directory containing your site (e.g. /var/www/docroot).'), '#states' => [ 'visible' => [ - ':input[name="version"]' => ['value' => 7], + ':input[name="version"]' => ['value' => '7'], ], ], ]; @@ -404,7 +455,7 @@ public function validateCredentialForm(array &$form, FormStateInterface $form_st try { $connection = $this->getConnection($database); - $version = $this->getLegacyDrupalVersion($connection); + $version = (string) $this->getLegacyDrupalVersion($connection); if (!$version) { $form_state->setErrorByName($database['driver'] . '][0', $this->t('Source database does not contain a recognizable Drupal version.')); } @@ -431,7 +482,7 @@ public function validateCredentialForm(array &$form, FormStateInterface $form_st // Store the retrieved migration IDs in form storage. $form_state->set('version', $version); $form_state->set('migrations', $migration_array); - if ($version == 6) { + if ($version == '6') { $form_state->set('source_base_path', $form_state->getValue('d6_source_base_path')); } else { @@ -661,9 +712,23 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) { // Get the source_module and destination_module from the field plugins. $definitions = $this->fieldPluginManager->getDefinitions(); foreach ($definitions as $definition) { - $source_module = $definition['source_module']; - $destination_module = $definition['destination_module']; - $table_data[$source_module][$destination_module][$definition['id']] = $definition['id']; + if (in_array($version, $definition['core'])) { + $source_module = $definition['source_module']; + $destination_module = $definition['destination_module']; + $table_data[$source_module][$destination_module][$definition['id']] = $definition['id']; + } + } + + // Fetch the system data at the first opportunity. + $system_data = $form_state->get('system_data'); + + // Add source_module and destination_module for modules that do not need an + // upgrade path and are enabled on the source site. + $no_upgrade_path = $form_state->get('no_upgrade_path'); + foreach ($no_upgrade_path[$version] as $module) { + if ($system_data['module'][$module]['status']) { + $table_data[$module]['core'][$module] = $module; + } } // Sort the table by source module names and within that destination @@ -673,8 +738,6 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) { ksort($table_data[$source_module]); } - // Fetch the system data at the first opportunity. - $system_data = $form_state->get('system_data'); // Remove core profiles from the system data. foreach (['standard', 'minimal'] as $profile) { unset($system_data['module'][$profile]); diff --git a/core/modules/migrate_drupal_ui/tests/modules/upgrade_form_alter_test/upgrade_form_alter_test.info.yml b/core/modules/migrate_drupal_ui/tests/modules/upgrade_form_alter_test/upgrade_form_alter_test.info.yml new file mode 100644 index 0000000000..c6b66cdb34 --- /dev/null +++ b/core/modules/migrate_drupal_ui/tests/modules/upgrade_form_alter_test/upgrade_form_alter_test.info.yml @@ -0,0 +1,6 @@ +name: 'Upgrade form alter test' +type: module +description: 'Tests that contrib modules can alter the upgrade form.' +package: Testing +version: VERSION +core: 8.x diff --git a/core/modules/migrate_drupal_ui/tests/modules/upgrade_form_alter_test/upgrade_form_alter_test.module b/core/modules/migrate_drupal_ui/tests/modules/upgrade_form_alter_test/upgrade_form_alter_test.module new file mode 100644 index 0000000000..499a0dbbe2 --- /dev/null +++ b/core/modules/migrate_drupal_ui/tests/modules/upgrade_form_alter_test/upgrade_form_alter_test.module @@ -0,0 +1,18 @@ +get('no_upgrade_path'); + $no_upgrade_path['6'][] = 'event'; + $no_upgrade_path['7'][] = 'book'; + $form_state->set('no_upgrade_path', $no_upgrade_path); +} diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php index 98c05aaef4..eafe5a4b56 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php @@ -37,6 +37,7 @@ */ public static $modules = [ 'language', + 'config_translation', 'content_translation', 'migrate_drupal_ui', 'telephone', @@ -44,7 +45,10 @@ 'book', 'forum', 'statistics', + 'tracker', + 'update', 'migration_provider_test', + 'upgrade_form_alter_test', ]; /** @@ -218,6 +222,10 @@ public function testMigrateUpgrade() { $session->elementNotExists('xpath', "//span[contains(@class, 'checked') and text() = '$missing']"); } + // Test the total count of missing and available paths. + $session->elementsCount('xpath', "//span[contains(@class, 'upgrade-analysis-report__status-icon--warning')]", count($this->getMissingPaths())); + $session->elementsCount('xpath', "//span[contains(@class, 'upgrade-analysis-report__status-icon--checked')]", count($this->getAvailablePaths())); + $this->drupalPostForm(NULL, [], t('Perform upgrade')); $this->assertText(t('Congratulations, you upgraded Drupal!')); diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php index 432b7036d7..5e3b83c62d 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php @@ -65,7 +65,7 @@ protected function getEntityCounts() { 'menu' => 8, 'taxonomy_term' => 8, 'taxonomy_vocabulary' => 7, - 'tour' => 4, + 'tour' => 5, 'user' => 7, 'user_role' => 6, 'menu_link_content' => 5, @@ -93,34 +93,45 @@ protected function getAvailablePaths() { 'date', 'dblog', 'email', - 'entityreference', - 'file', 'filefield', 'filter', + 'forum', + 'i18nprofile', 'i18ntaxonomy', - 'image', 'imagecache', 'imagefield', + 'language', 'link', - 'list', - 'menu', 'locale', + 'menu', 'node', - 'node_reference', - 'number', - 'options', + 'nodereference', 'optionwidgets', 'path', - 'phone', - 'profile', 'search', + 'statistics', 'system', 'taxonomy', 'text', 'translation', + 'update', 'upload', 'user', - 'user_reference', + 'userreference', + // Modules that have no upgrade path. + 'date_api', + 'date_timezone', + 'i18n', + 'i18nstrings', + 'imageapi', + 'number', + 'php', + 'profile', + 'variable_admin', + // To test that contrib modules can alter this list, Event is added here + // by a hook_form_alter(). + // See upgrade_form_alter_test_form_migrate_drupal_ui_form_alter(). + 'event', ]; } @@ -129,19 +140,14 @@ protected function getAvailablePaths() { */ protected function getMissingPaths() { return [ - 'date_api', - 'date_timezone', - 'event', - 'i18n', + // To test that contrib modules can alter this list, Event is removed from + // here by a hook_form_alter(). + // See upgrade_form_alter_test_form_migrate_drupal_ui_form_alter(). + // 'event', 'i18nblocks', 'i18ncck', 'i18ncontent', 'i18nmenu', - 'i18nprofile', - 'i18nstrings', - 'imageapi', - 'php', - 'variable_admin', ]; } diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php index 608967c754..0cbd239883 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php @@ -69,7 +69,7 @@ protected function getEntityCounts() { 'menu' => 6, 'taxonomy_term' => 18, 'taxonomy_vocabulary' => 4, - 'tour' => 4, + 'tour' => 5, 'user' => 4, 'user_role' => 3, 'menu_link_content' => 8, @@ -99,20 +99,17 @@ protected function getAvailablePaths() { 'field', 'field_sql_storage', 'file', - 'filefield', 'filter', 'forum', 'image', - 'imagefield', + 'language', 'link', 'list', 'locale', 'menu', 'node', - 'node_reference', 'number', 'options', - 'optionwidgets', 'path', 'phone', 'search', @@ -121,33 +118,40 @@ protected function getAvailablePaths() { 'system', 'taxonomy', 'text', + 'tracker', 'translation', + 'update', 'user', - 'user_reference', - ]; - } - - /** - * {@inheritdoc} - */ - protected function getMissingPaths() { - return [ + // Modules that have no upgrade path. 'blog', - 'book', - 'color', 'contextual', 'date_api', 'entity', 'field_ui', 'help', 'php', - 'rdf', 'simpletest', 'syslog', 'toolbar', - 'tracker', 'trigger', - 'update', + // To test that contrib modules can alter this list, Book is added here + // by a hook_form_alter(). + // See upgrade_form_alter_test_form_migrate_drupal_ui_form_alter(). + 'book', + ]; + } + + /** + * {@inheritdoc} + */ + protected function getMissingPaths() { + return [ + // To test that contrib modules can alter this list, Book is removed from + // here by a hook_form_alter(). + // See upgrade_form_alter_test_form_migrate_drupal_ui_form_alter(). + // 'book', + 'color', + 'rdf', ]; }