diff -u b/core/modules/user/migration_templates/d6_user.yml b/core/modules/user/migration_templates/d6_user.yml --- b/core/modules/user/migration_templates/d6_user.yml +++ b/core/modules/user/migration_templates/d6_user.yml @@ -4,7 +4,6 @@ - Drupal 6 source: plugin: d6_user - provider: user process: uid: uid name: name diff -u b/core/modules/user/migration_templates/d6_user_contact_settings.yml b/core/modules/user/migration_templates/d6_user_contact_settings.yml --- b/core/modules/user/migration_templates/d6_user_contact_settings.yml +++ b/core/modules/user/migration_templates/d6_user_contact_settings.yml @@ -7,7 +7,6 @@ constants: key: contact module: contact - provider: user process: uid: uid key: 'constants/key' diff -u b/core/modules/user/migration_templates/d7_user.yml b/core/modules/user/migration_templates/d7_user.yml --- b/core/modules/user/migration_templates/d7_user.yml +++ b/core/modules/user/migration_templates/d7_user.yml @@ -5,7 +5,6 @@ class: Drupal\user\Plugin\migrate\User source: plugin: d7_user - provider: user process: uid: uid name: name only in patch2: unchanged: --- a/core/modules/menu_link_content/migration_templates/d6_menu_links.yml +++ b/core/modules/menu_link_content/migration_templates/d6_menu_links.yml @@ -51,6 +51,7 @@ destination: plugin: entity:menu_link_content default_bundle: menu_link_content no_stub: true + provider: menu_link_content migration_dependencies: required: - d6_menu only in patch2: unchanged: --- a/core/modules/menu_link_content/migration_templates/d7_menu_links.yml +++ b/core/modules/menu_link_content/migration_templates/d7_menu_links.yml @@ -47,6 +47,7 @@ process: destination: plugin: entity:menu_link_content no_stub: true + provider: menu_link_content migration_dependencies: required: - d7_menu only in patch2: unchanged: --- a/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php +++ b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php @@ -23,610 +23,9 @@ class MigrateUpgradeForm extends ConfirmFormBase { /** * Mapping of known migrations and their source and destination modules. * - * @todo https://www.drupal.org/node/2569805 Hardcoding this information is - * not robust - the migrations themselves should hold the necessary - * information. - * * @var array[] */ - protected $moduleUpgradePaths = [ - 'action_settings' => [ - 'source_module' => 'system', - 'destination_module' => 'action', - ], - 'd6_aggregator_feed' => [ - 'source_module' => 'aggregator', - 'destination_module' => 'aggregator', - ], - 'd6_aggregator_item' => [ - 'source_module' => 'aggregator', - 'destination_module' => 'aggregator', - ], - 'd6_aggregator_settings' => [ - 'source_module' => 'aggregator', - 'destination_module' => 'aggregator', - ], - 'd7_aggregator_feed' => [ - 'source_module' => 'aggregator', - 'destination_module' => 'aggregator', - ], - 'd7_aggregator_item' => [ - 'source_module' => 'aggregator', - 'destination_module' => 'aggregator', - ], - 'd7_aggregator_settings' => [ - 'source_module' => 'aggregator', - 'destination_module' => 'aggregator', - ], - 'd7_blocked_ips' => [ - 'source_module' => 'system', - 'destination_module' => 'ban', - ], - 'd6_block' => [ - 'source_module' => 'block', - 'destination_module' => 'block', - ], - 'd7_block' => [ - 'source_module' => 'block', - 'destination_module' => 'block', - ], - 'block_content_body_field' => [ - 'source_module' => 'block', - 'destination_module' => 'block_content', - ], - 'block_content_type' => [ - 'source_module' => 'block', - 'destination_module' => 'block_content', - ], - 'd6_custom_block' => [ - 'source_module' => 'block', - 'destination_module' => 'block_content', - ], - 'd7_custom_block' => [ - 'source_module' => 'block', - 'destination_module' => 'block_content', - ], - 'd6_book' => [ - 'source_module' => 'book', - 'destination_module' => 'book', - ], - 'd6_book_settings' => [ - 'source_module' => 'book', - 'destination_module' => 'book', - ], - 'd6_comment' => [ - 'source_module' => 'comment', - 'destination_module' => 'comment', - ], - 'd6_comment_entity_display' => [ - 'source_module' => 'comment', - 'destination_module' => 'comment', - ], - 'd6_comment_entity_form_display' => [ - 'source_module' => 'comment', - 'destination_module' => 'comment', - ], - 'd6_comment_entity_form_display_subject' => [ - 'source_module' => 'comment', - 'destination_module' => 'comment', - ], - 'd6_comment_field' => [ - 'source_module' => 'comment', - 'destination_module' => 'comment', - ], - 'd6_comment_field_instance' => [ - 'source_module' => 'comment', - 'destination_module' => 'comment', - ], - 'd6_comment_type' => [ - 'source_module' => 'comment', - 'destination_module' => 'comment', - ], - 'd7_comment' => [ - 'source_module' => 'comment', - 'destination_module' => 'comment', - ], - 'd7_comment_entity_display' => [ - 'source_module' => 'comment', - 'destination_module' => 'comment', - ], - 'd7_comment_entity_form_display' => [ - 'source_module' => 'comment', - 'destination_module' => 'comment', - ], - 'd7_comment_entity_form_display_subject' => [ - 'source_module' => 'comment', - 'destination_module' => 'comment', - ], - 'd7_comment_field' => [ - 'source_module' => 'comment', - 'destination_module' => 'comment', - ], - 'd7_comment_field_instance' => [ - 'source_module' => 'comment', - 'destination_module' => 'comment', - ], - 'd7_comment_type' => [ - 'source_module' => 'comment', - 'destination_module' => 'comment', - ], - 'contact_category' => [ - 'source_module' => 'contact', - 'destination_module' => 'contact', - ], - 'd6_contact_settings' => [ - 'source_module' => 'contact', - 'destination_module' => 'contact', - ], - 'd7_contact_settings' => [ - 'source_module' => 'contact', - 'destination_module' => 'contact', - ], - 'd6_dblog_settings' => [ - 'source_module' => 'dblog', - 'destination_module' => 'dblog', - ], - 'd7_dblog_settings' => [ - 'source_module' => 'dblog', - 'destination_module' => 'dblog', - ], - 'default_language' => [ - 'source_module' => 'locale', - 'destination_module' => 'language', - ], - 'd6_field' => [ - 'source_module' => 'content', - 'destination_module' => 'field', - ], - 'd6_field_formatter_settings' => [ - 'source_module' => 'content', - 'destination_module' => 'field', - ], - 'd6_field_instance' => [ - 'source_module' => 'content', - 'destination_module' => 'field', - ], - 'd6_field_instance_widget_settings' => [ - 'source_module' => 'content', - 'destination_module' => 'field', - ], - 'd7_field' => [ - 'source_module' => 'field', - 'destination_module' => 'field', - ], - 'd7_field_formatter_settings' => [ - 'source_module' => 'field', - 'destination_module' => 'field', - ], - 'd7_field_instance' => [ - 'source_module' => 'field', - 'destination_module' => 'field', - ], - 'd7_field_instance_widget_settings' => [ - 'source_module' => 'field', - 'destination_module' => 'field', - ], - 'd7_view_modes' => [ - 'source_module' => 'field', - 'destination_module' => 'field', - ], - 'd6_file' => [ - 'source_module' => 'system', - 'destination_module' => 'file', - ], - 'file_settings' => [ - 'source_module' => 'system', - 'destination_module' => 'file', - ], - 'd6_upload' => [ - 'source_module' => 'upload', - 'destination_module' => 'file', - ], - 'd6_upload_entity_display' => [ - 'source_module' => 'upload', - 'destination_module' => 'file', - ], - 'd6_upload_entity_form_display' => [ - 'source_module' => 'upload', - 'destination_module' => 'file', - ], - 'd6_upload_field' => [ - 'source_module' => 'upload', - 'destination_module' => 'file', - ], - 'd6_upload_field_instance' => [ - 'source_module' => 'upload', - 'destination_module' => 'file', - ], - 'd7_file' => [ - 'source_module' => 'file', - 'destination_module' => 'file', - ], - 'd6_filter_format' => [ - 'source_module' => 'filter', - 'destination_module' => 'filter', - ], - 'd7_filter_format' => [ - 'source_module' => 'filter', - 'destination_module' => 'filter', - ], - 'd6_forum_settings' => [ - 'source_module' => 'forum', - 'destination_module' => 'forum', - ], - 'd7_forum_settings' => [ - 'source_module' => 'forum', - 'destination_module' => 'forum', - ], - 'd6_imagecache_presets' => [ - 'source_module' => 'imagecache', - 'destination_module' => 'image', - ], - 'd7_image_settings' => [ - 'source_module' => 'image', - 'destination_module' => 'image', - ], - 'd7_image_styles' => [ - 'source_module' => 'image', - 'destination_module' => 'image', - ], - 'd6_language_content_settings' => [ - 'source_module' => 'locale', - 'destination_module' => 'language', - ], - 'd7_language_content_settings' => [ - 'source_module' => 'locale', - 'destination_module' => 'language', - ], - 'd7_language_negotiation_settings' => [ - 'source_module' => 'locale', - 'destination_module' => 'language', - ], - 'language' => [ - 'source_module' => 'locale', - 'destination_module' => 'language', - ], - 'locale_settings' => [ - 'source_module' => 'locale', - 'destination_module' => 'locale', - ], - 'd6_menu_links' => [ - 'source_module' => 'menu', - 'destination_module' => 'menu_link_content', - ], - 'menu_settings' => [ - 'source_module' => 'menu', - 'destination_module' => 'menu_ui', - ], - 'd7_menu_links' => [ - 'source_module' => 'menu', - 'destination_module' => 'menu_link_content', - ], - 'd6_node' => [ - 'source_module' => 'node', - 'destination_module' => 'node', - ], - 'd6_node_translation' => [ - 'source_module' => 'translation', - 'destination_module' => 'content_translation', - ], - 'd6_node_revision' => [ - 'source_module' => 'node', - 'destination_module' => 'node', - ], - 'd6_node_setting_promote' => [ - 'source_module' => 'node', - 'destination_module' => 'node', - ], - 'd6_node_setting_status' => [ - 'source_module' => 'node', - 'destination_module' => 'node', - ], - 'd6_node_setting_sticky' => [ - 'source_module' => 'node', - 'destination_module' => 'node', - ], - 'd6_node_settings' => [ - 'source_module' => 'node', - 'destination_module' => 'node', - ], - 'd6_node_type' => [ - 'source_module' => 'node', - 'destination_module' => 'node', - ], - 'd6_view_modes' => [ - 'source_module' => 'node', - 'destination_module' => 'node', - ], - 'd7_node' => [ - 'source_module' => 'node', - 'destination_module' => 'node', - ], - 'd7_node_revision' => [ - 'source_module' => 'node', - 'destination_module' => 'node', - ], - 'd7_node_settings' => [ - 'source_module' => 'node', - 'destination_module' => 'node', - ], - 'd7_node_title_label' => [ - 'source_module' => 'node', - 'destination_module' => 'node', - ], - 'd7_node_type' => [ - 'source_module' => 'node', - 'destination_module' => 'node', - ], - 'd6_url_alias' => [ - 'source_module' => 'path', - 'destination_module' => 'path', - ], - 'd7_url_alias' => [ - 'source_module' => 'path', - 'destination_module' => 'path', - ], - 'search_page' => [ - 'source_module' => 'search', - 'destination_module' => 'search', - ], - 'd6_search_settings' => [ - 'source_module' => 'search', - 'destination_module' => 'search', - ], - 'd7_search_settings' => [ - 'source_module' => 'search', - 'destination_module' => 'search', - ], - 'd7_shortcut' => [ - 'source_module' => 'shortcut', - 'destination_module' => 'shortcut', - ], - 'd7_shortcut_set' => [ - 'source_module' => 'shortcut', - 'destination_module' => 'shortcut', - ], - 'd7_shortcut_set_users' => [ - 'source_module' => 'shortcut', - 'destination_module' => 'shortcut', - ], - 'd6_simpletest_settings' => [ - 'source_module' => 'simpletest', - 'destination_module' => 'simpletest', - ], - 'd7_simpletest_settings' => [ - 'source_module' => 'simpletest', - 'destination_module' => 'simpletest', - ], - 'd6_statistics_settings' => [ - 'source_module' => 'statistics', - 'destination_module' => 'statistics', - ], - 'd6_syslog_settings' => [ - 'source_module' => 'syslog', - 'destination_module' => 'syslog', - ], - 'd7_syslog_settings' => [ - 'source_module' => 'syslog', - 'destination_module' => 'syslog', - ], - 'd6_date_formats' => [ - 'source_module' => 'system', - 'destination_module' => 'system', - ], - 'd6_system_cron' => [ - 'source_module' => 'system', - 'destination_module' => 'system', - ], - 'd6_system_date' => [ - 'source_module' => 'system', - 'destination_module' => 'system', - ], - 'd6_system_file' => [ - 'source_module' => 'system', - 'destination_module' => 'system', - ], - 'system_image' => [ - 'source_module' => 'system', - 'destination_module' => 'system', - ], - 'system_image_gd' => [ - 'source_module' => 'system', - 'destination_module' => 'system', - ], - 'system_logging' => [ - 'source_module' => 'system', - 'destination_module' => 'system', - ], - 'system_maintenance' => [ - 'source_module' => 'system', - 'destination_module' => 'system', - ], - 'd6_system_performance' => [ - 'source_module' => 'system', - 'destination_module' => 'system', - ], - 'system_rss' => [ - 'source_module' => 'system', - 'destination_module' => 'system', - ], - 'system_site' => [ - 'source_module' => 'system', - 'destination_module' => 'system', - ], - 'd7_system_authorize' => [ - 'source_module' => 'system', - 'destination_module' => 'system', - ], - 'd7_system_cron' => [ - 'source_module' => 'system', - 'destination_module' => 'system', - ], - 'd7_system_date' => [ - 'source_module' => 'system', - 'destination_module' => 'system', - ], - 'd7_system_file' => [ - 'source_module' => 'system', - 'destination_module' => 'system', - ], - 'd7_system_mail' => [ - 'source_module' => 'system', - 'destination_module' => 'system', - ], - 'd7_system_performance' => [ - 'source_module' => 'system', - 'destination_module' => 'system', - ], - 'd6_menu' => [ - 'source_module' => 'menu', - 'destination_module' => 'system', - ], - 'd7_menu' => [ - 'source_module' => 'menu', - 'destination_module' => 'system', - ], - 'taxonomy_settings' => [ - 'source_module' => 'taxonomy', - 'destination_module' => 'taxonomy', - ], - 'd6_taxonomy_term' => [ - 'source_module' => 'taxonomy', - 'destination_module' => 'taxonomy', - ], - 'd6_taxonomy_vocabulary' => [ - 'source_module' => 'taxonomy', - 'destination_module' => 'taxonomy', - ], - 'd6_term_node' => [ - 'source_module' => 'taxonomy', - 'destination_module' => 'taxonomy', - ], - 'd6_term_node_revision' => [ - 'source_module' => 'taxonomy', - 'destination_module' => 'taxonomy', - ], - 'd6_vocabulary_entity_display' => [ - 'source_module' => 'taxonomy', - 'destination_module' => 'taxonomy', - ], - 'd6_vocabulary_entity_form_display' => [ - 'source_module' => 'taxonomy', - 'destination_module' => 'taxonomy', - ], - 'd6_vocabulary_field' => [ - 'source_module' => 'taxonomy', - 'destination_module' => 'taxonomy', - ], - 'd6_vocabulary_field_instance' => [ - 'source_module' => 'taxonomy', - 'destination_module' => 'taxonomy', - ], - 'd7_taxonomy_term' => [ - 'source_module' => 'taxonomy', - 'destination_module' => 'taxonomy', - ], - 'd7_taxonomy_vocabulary' => [ - 'source_module' => 'taxonomy', - 'destination_module' => 'taxonomy', - ], - 'text_settings' => [ - 'source_module' => 'text', - 'destination_module' => 'text', - ], - 'd7_tracker_node' => [ - 'source_module' => 'tracker', - 'destination_module' => 'tracker', - ], - 'd7_tracker_settings' => [ - 'source_module' => 'tracker', - 'destination_module' => 'tracker', - ], - 'd7_tracker_user' => [ - 'source_module' => 'tracker', - 'destination_module' => 'tracker', - ], - 'update_settings' => [ - 'source_module' => 'update', - 'destination_module' => 'update', - ], - 'd6_profile_values' => [ - 'source_module' => 'profile', - 'destination_module' => 'user', - ], - 'd6_user' => [ - 'source_module' => 'user', - 'destination_module' => 'user', - ], - 'd6_user_contact_settings' => [ - 'source_module' => 'user', - 'destination_module' => 'user', - ], - 'd6_user_mail' => [ - 'source_module' => 'user', - 'destination_module' => 'user', - ], - 'd6_user_picture_file' => [ - 'source_module' => 'user', - 'destination_module' => 'user', - ], - 'd6_user_role' => [ - 'source_module' => 'user', - 'destination_module' => 'user', - ], - 'd6_user_settings' => [ - 'source_module' => 'user', - 'destination_module' => 'user', - ], - 'd7_user' => [ - 'source_module' => 'user', - 'destination_module' => 'user', - ], - 'd7_user_flood' => [ - 'source_module' => 'user', - 'destination_module' => 'user', - ], - 'd7_user_mail' => [ - 'source_module' => 'user', - 'destination_module' => 'user', - ], - 'd7_user_role' => [ - 'source_module' => 'user', - 'destination_module' => 'user', - ], - 'user_picture_entity_display' => [ - 'source_module' => 'user', - 'destination_module' => 'user', - ], - 'user_picture_entity_form_display' => [ - 'source_module' => 'user', - 'destination_module' => 'user', - ], - 'user_picture_field' => [ - 'source_module' => 'user', - 'destination_module' => 'user', - ], - 'user_picture_field_instance' => [ - 'source_module' => 'user', - 'destination_module' => 'user', - ], - 'user_profile_entity_display' => [ - 'source_module' => 'profile', - 'destination_module' => 'user', - ], - 'user_profile_entity_form_display' => [ - 'source_module' => 'profile', - 'destination_module' => 'user', - ], - 'user_profile_field' => [ - 'source_module' => 'profile', - 'destination_module' => 'user', - ], - 'user_profile_field_instance' => [ - 'source_module' => 'profile', - 'destination_module' => 'user', - ], - ]; + protected $moduleUpgradePaths = []; /** * The state service. @@ -952,6 +351,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); $form_state->set('source_base_path', $form_state->getValue('source_base_path')); @@ -1006,26 +406,75 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) { $form['actions']['submit']['#value'] = $this->t('Perform upgrade'); + $version = $form_state->get('version'); + $migrations = $this->getMigrations('migrate_drupal_' . $version, $version); + $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'); + foreach ($migrations as $migration) { + $migration_id = $migration->getPluginId(); + + // Determine the source provider. + $source_plugin_provider = (!empty($migration->getSourcePlugin() + ->getPluginDefinition()['source_provider'])) ? $migration->getSourcePlugin() + ->getPluginDefinition()['source_provider'] : NULL; + // Provider in the configuration. + $source_provider = (!empty($migration->getSourceConfiguration()['provider'])) ? $migration->getSourceConfiguration()['provider'] : NULL; + + $source_module = ''; + if ($source_plugin_provider && !$source_provider) { + $source_module = $source_plugin_provider; + } + if (!$source_plugin_provider && $source_provider) { + $source_module = $source_provider; + } + if (!$source_module) { + if ($source_plugin_provider && $source_provider) { + drupal_set_message(t('Source provider exists in source plugin and migration @migration_id.', ['@migration_id' => $migration_id]), 'error'); + + } + else { + drupal_set_message(t('Source provider not found for @migration_id.', ['@migration_id' => $migration_id]), 'error'); + } } - // 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; + // Determine the destination provider. + $destination_module = ''; + $destination_provider = (!empty($migration->getDestinationConfiguration()['provider'])) ? $migration->getDestinationConfiguration()['provider'] : NULL; + if ($destination_provider) { + // Source plugin provider and destination provider. + $destination_module = $destination_provider; + } + else { + if ($migration->getDestinationPlugin()->getPluginId() == 'config') { + $configuration_destination = (!empty($migration->getDestinationConfiguration()['config_name'])) ? $migration->getDestinationConfiguration()['config_name'] : NULL; + if ($configuration_destination) { + $destination_module = explode('.', $configuration_destination, 2)[0]; + } + } + else { + drupal_set_message(t('Destination provider not found for @migration_id.', ['@migration_id' => $migration_id]), 'error'); + } + } + + if ($source_module && $destination_module) { + $this->moduleUpgradePaths[$migration_id]['source_module'] = $source_module; + $this->moduleUpgradePaths[$migration_id]['destination_module'] = $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]); } + + $system_data = []; + // 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. only in patch2: unchanged: --- a/core/modules/system/migration_templates/d6_menu.yml +++ b/core/modules/system/migration_templates/d6_menu.yml @@ -11,3 +11,4 @@ process: description: description destination: plugin: entity:menu + provider: system only in patch2: unchanged: --- a/core/modules/system/migration_templates/d7_menu.yml +++ b/core/modules/system/migration_templates/d7_menu.yml @@ -18,3 +18,4 @@ process: description: description destination: plugin: entity:menu + provider: system only in patch2: unchanged: --- a/core/modules/user/src/Plugin/migrate/source/d7/User.php +++ b/core/modules/user/src/Plugin/migrate/source/d7/User.php @@ -9,7 +9,8 @@ * Drupal 7 user source from database. * * @MigrateSource( - * id = "d7_user" + * id = "d7_user", + * source_provider = "user" * ) */ class User extends FieldableEntity {