diff --git a/core/modules/drupal_upgrade/drupal_upgrade.info.yml b/core/modules/drupal_upgrade/drupal_upgrade.info.yml new file mode 100644 index 0000000..0615e41 --- /dev/null +++ b/core/modules/drupal_upgrade/drupal_upgrade.info.yml @@ -0,0 +1,11 @@ +name: Drupal Upgrade +type: module +description: 'UI for direct upgrades from older Drupal versions.' +package: Core (Experimental) +version: VERSION +core: 8.x +configure: drupal_upgrade.upgrade +dependencies: + - migrate + - migrate_drupal + - dblog diff --git a/core/modules/drupal_upgrade/drupal_upgrade.install b/core/modules/drupal_upgrade/drupal_upgrade.install new file mode 100644 index 0000000..94ac744 --- /dev/null +++ b/core/modules/drupal_upgrade/drupal_upgrade.install @@ -0,0 +1,16 @@ +toString(); + drupal_set_message(t("The Drupal Upgrade module has been enabled. Proceed to the upgrade form.", ['@url' => $url])); +} diff --git a/core/modules/drupal_upgrade/drupal_upgrade.module b/core/modules/drupal_upgrade/drupal_upgrade.module new file mode 100644 index 0000000..5d3e1c2 --- /dev/null +++ b/core/modules/drupal_upgrade/drupal_upgrade.module @@ -0,0 +1,19 @@ +' . t('The Drupal Upgrade UI module provides a one-click upgrade from an earlier version of Drupal. For more details, see upgrading from previous versions.', [':migrate' => 'https://www.drupal.org/upgrade/migrate']) . '

'; + return $output; + } +} diff --git a/core/modules/drupal_upgrade/drupal_upgrade.routing.yml b/core/modules/drupal_upgrade/drupal_upgrade.routing.yml new file mode 100644 index 0000000..4842376 --- /dev/null +++ b/core/modules/drupal_upgrade/drupal_upgrade.routing.yml @@ -0,0 +1,18 @@ +drupal_upgrade.upgrade: + path: '/upgrade' + defaults: + _form: '\Drupal\drupal_upgrade\Form\MigrateUpgradeForm' + _title: 'Upgrade' + requirements: + _permission: 'administer software updates' + options: + _admin_route: TRUE + +drupal_upgrade.log: + path: '/upgrade/log' + defaults: + _controller: '\Drupal\drupal_upgrade\Controller\MigrateController::showLog' + requirements: + _permission: 'administer software updates' + options: + _admin_route: TRUE diff --git a/core/modules/drupal_upgrade/src/Controller/MigrateController.php b/core/modules/drupal_upgrade/src/Controller/MigrateController.php new file mode 100644 index 0000000..b46fc77 --- /dev/null +++ b/core/modules/drupal_upgrade/src/Controller/MigrateController.php @@ -0,0 +1,24 @@ + 'drupal_upgrade']; + return $this->redirect('dblog.overview'); + } +} diff --git a/core/modules/drupal_upgrade/src/DrushLogMigrateMessage.php b/core/modules/drupal_upgrade/src/DrushLogMigrateMessage.php new file mode 100644 index 0000000..7f075cb --- /dev/null +++ b/core/modules/drupal_upgrade/src/DrushLogMigrateMessage.php @@ -0,0 +1,28 @@ + [ + '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_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', + ], + 'd6_contact_category' => [ + 'source_module' => 'contact', + 'destination_module' => 'contact', + ], + 'd6_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', + ], + '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', + ], + 'd6_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_language_negotiation_settings' => [ + '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', + ], + 'd7_menu_links' => [ + 'source_module' => 'menu', + 'destination_module' => 'menu_link_content', + ], + 'menu_settings' => [ + 'source_module' => 'menu', + 'destination_module' => 'menu_ui', + ], + 'd6_node' => [ + 'source_module' => 'node', + 'destination_module' => 'node', + ], + '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', + ], + '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', + ], + 'd6_system_image' => [ + 'source_module' => 'system', + 'destination_module' => 'system', + ], + 'd6_system_image_gd' => [ + 'source_module' => 'system', + 'destination_module' => 'system', + ], + 'd6_system_logging' => [ + 'source_module' => 'system', + 'destination_module' => 'system', + ], + 'd6_system_maintenance' => [ + 'source_module' => 'system', + 'destination_module' => 'system', + ], + 'd6_system_performance' => [ + 'source_module' => 'system', + 'destination_module' => 'system', + ], + 'd6_system_rss' => [ + 'source_module' => 'system', + 'destination_module' => 'system', + ], + 'd6_system_site' => [ + 'source_module' => 'system', + 'destination_module' => 'system', + ], + '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_settings' => [ + 'source_module' => 'tracker', + 'destination_module' => 'tracker', + ], + 'd6_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', + ], + ]; + + /** + * {@inheritdoc} + */ + public function getFormId() { + return 'drupal_upgrade_form'; + } + + /** + * {@inheritdoc} + */ + public function buildForm(array $form, FormStateInterface $form_state) { + $step = $form_state->getValue('step', 'overview'); + switch ($step) { + case 'overview': + return $this->buildOverviewForm($form, $form_state); + case 'credentials': + return $this->buildCredentialForm($form, $form_state); + case 'confirm': + return $this->buildConfirmForm($form, $form_state); + default: + drupal_set_message($this->t('Unrecognized form step @step', + ['@step' => $step]), 'error'); + return []; + } + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) {} + + /** + * Build the form presenting an overview of the migration process. + * + * @param array $form + * An associative array containing the structure of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. + * + * @return array + * The form structure. + */ + public function buildOverviewForm(array $form, FormStateInterface $form_state) { + $form['#title'] = $this->t('Drupal Upgrade'); + + if ($date_performed = \Drupal::state()->get('drupal_upgrade.performed')) { + $form['upgrade_option_item'] = [ + '#type' => 'item', + '#prefix' => t('

An upgrade has already been performed on this site.

'), + '#description' => t('

Last upgrade: @date

', + ['@date' => \Drupal::service('date.formatter')->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']; + } + else { + $form['info_header'] = [ + '#markup' => '

' . $this->t('Upgrade a Drupal site by importing it into a clean and empty new install of Drupal 8. You will lose any existing configuration once you import your site into it. See the upgrading handbook for more detailed information.', [ + ':url' => 'https://www.drupal.org/upgrade/migrate' + ]), + ]; + + $info[] = $this->t('Back up the database for this site. Upgrade will change the database for this site.'); + $info[] = $this->t('Make sure that the host this site is on has access to the database for your previous site.'); + $info[] = $this->t('If your previous site has private files to be migrated, a copy of your files directory must be accessible on the host this site is on.'); + $info[] = $this->t('In general, enable all modules on this site that are enabled on the previous site. For example, if you have used the book module on the previous site then you must enable the book module on this site for that data to be available on this site.'); + $info[] = $this->t('Put this site into maintenance mode.', [ + ':url' => Url::fromRoute('system.site_maintenance_mode') + ->toString(TRUE) + ->getGeneratedUrl(), + ]); + + $form['info'] = [ + '#theme' => 'item_list', + '#list_type' => 'ol', + '#items' => $info, + ]; + + $form['info_footer'] = [ + '#markup' => '

' . $this->t('This upgrade can take a long time. It is better to import a local copy of your site instead of directly importing from your live site.'), + ]; + + $validate = []; + } + + $form['actions'] = ['#type' => 'actions']; + $form['actions']['save'] = [ + '#type' => 'submit', + '#value' => $this->t('Continue'), + '#button_type' => 'primary', + '#validate' => $validate, + '#submit' => ['::submitOverviewForm'], + ]; + return $form; + } + + /** + * Overview form submission handler. + * + * @param array $form + * An associative array containing the structure of the form. + * @param \Drupal\Core\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(); + } + + /** + * Build the form gathering database credential and file location information. + * This is largely borrowed from SiteSettingsForm. + * + * @param array $form + * An associative array containing the structure of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. + * + * @return array + * The form structure. + */ + public function buildCredentialForm(array $form, FormStateInterface $form_state) { + // Make sure the install API is available. + include_once DRUPAL_ROOT . '/core/includes/install.inc'; + + $form['#title'] = $this->t('Drupal Upgrade'); + + $drivers = drupal_get_database_types(); + $drivers_keys = array_keys($drivers); + $default_driver = current($drivers_keys); + $default_options = []; + + $form['database'] = [ + '#type' => 'details', + '#title' => $this->t('Source database'), + '#description' => $this->t('Provide credentials for the database of the Drupal site you want to upgrade.'), + '#open' => TRUE, + ]; + + $form['database']['driver'] = [ + '#type' => 'radios', + '#title' => $this->t('Database type'), + '#required' => TRUE, + '#default_value' => $default_driver, + ]; + if (count($drivers) == 1) { + $form['database']['driver']['#disabled'] = TRUE; + } + + // Add driver specific configuration options. + foreach ($drivers as $key => $driver) { + $form['database']['driver']['#options'][$key] = $driver->name(); + + $form['database']['settings'][$key] = $driver->getFormOptions($default_options); + $form['database']['settings'][$key]['#prefix'] = '

' . $this->t('@driver_name settings', ['@driver_name' => $driver->name()]) . '

'; + $form['database']['settings'][$key]['#type'] = 'container'; + $form['database']['settings'][$key]['#tree'] = TRUE; + $form['database']['settings'][$key]['advanced_options']['#parents'] = [$key]; + $form['database']['settings'][$key]['#states'] = [ + 'visible' => [ + ':input[name=driver]' => ['value' => $key], + ] + ]; + } + + // Move the host fields out of advanced settings. + $form['database']['settings']['mysql']['host'] = $form['database']['settings']['mysql']['advanced_options']['host']; + $form['database']['settings']['mysql']['host']['#title'] = 'Database host'; + $form['database']['settings']['mysql']['host']['#weight'] = -1; + unset($form['database']['settings']['mysql']['database']['#default_value']); + unset($form['database']['settings']['mysql']['advanced_options']['host']); + + $form['database']['settings']['pgsql']['host'] = $form['database']['settings']['pgsql']['advanced_options']['host']; + $form['database']['settings']['pgsql']['host']['#title'] = 'Database host'; + $form['database']['settings']['pgsql']['host']['#weight'] = -1; + unset($form['database']['settings']['pgsql']['database']['#default_value']); + unset($form['database']['settings']['pgsql']['advanced_options']['host']); + + $form['source'] = [ + '#type' => 'details', + '#title' => $this->t('Source files'), + '#open' => TRUE, + ]; + $form['source']['source_base_path'] = [ + '#type' => 'textfield', + '#title' => $this->t('Files directory'), + '#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 (e.g. http://example.com).'), + ]; + + /* + // @todo: Not yet implemented, depends on https://www.drupal.org/node/2547125. + $form['files']['private_file_directory'] = [ + '#type' => 'textfield', + '#title' => $this->t('Private file path'), + '#description' => $this->t('To import private files from your current Drupal site, enter a local file directory containing your files (e.g. /var/private_files).'), + ]; + */ + + $form['actions'] = ['#type' => 'actions']; + $form['actions']['save'] = [ + '#type' => 'submit', + '#value' => $this->t('Review upgrade'), + '#button_type' => 'primary', + '#limit_validation_errors' => [ + ['driver'], + [$default_driver], + ], + '#validate' => ['::validateCredentialForm'], + '#submit' => ['::submitCredentialForm'], + ]; + return $form; + } + + /** + * Credential form validation handler. + * + * @param array $form + * An associative array containing the structure of the form. + * @param \Drupal\Core\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')) { + $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; + + // 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 { + // Find a migration which has database credentials and use those. + $query = \Drupal::entityQuery('migration', 'OR'); + $ids = $query->execute(); + foreach ($ids as $id) { + /** @var MigrationInterface $migration */ + $migration = Migration::load($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 = \Drupal::state()->get($source['database_state_key'])['database']) { + break; + } + } + } + } + + try { + // Create all the relevant migrations and get their IDs so we can run them. + $migration_ids = $this->createMigrations($database, $form_state->getValue('source_base_path')); + + // Store the retrieved migration ids in form storage. + $form_state->set('migration_ids', $migration_ids); + } + catch (\Exception $e) { + $error_message = [ + '#type' => 'inline_template', + '#template' => '{% trans %}Resolve the issue below to continue the upgrade.{% endtrans%}{{ errors }}', + '#context' => [ + 'errors' => [ + '#theme' => 'item_list', + '#items' => [$e->getMessage()], + ], + ], + ]; + + $form_state->setErrorByName($database['driver'] . '][0', \Drupal::service('renderer')->renderPlain($error_message)); + } + } + + /** + * Credential form submission handler. + * + * @param array $form + * An associative array containing the structure of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. + */ + public function submitCredentialForm(array &$form, FormStateInterface $form_state) { + // Indicate the next step is confirmation. + $form_state->setValue('step', 'confirm'); + $form_state->setRebuild(); + } + + /** + * Build the form gathering database credential and file location information. + * + * @param array $form + * An associative array containing the structure of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. + * + * @return array + * The form structure. + */ + public function buildConfirmForm(array $form, FormStateInterface $form_state) { + $rollback = $form_state->getValue('upgrade_option') == static::MIGRATE_UPGRADE_ROLLBACK; + if ($rollback) { + $form_state->setStorage(['upgrade_option' => static::MIGRATE_UPGRADE_ROLLBACK]); + } + $form['#title'] = $this->getQuestion(); + + $form['#attributes']['class'][] = 'confirmation'; + $form[$this->getFormName()] = ['#type' => 'hidden', '#value' => 1]; + + if ($rollback) { + $form['rollback'] = [ + '#markup' => $this->t('All previously-imported content, as well as configuration such as field definitions, will be removed.'), + ]; + } + else { + $table_data = []; + $system_data = []; + foreach ($form_state->get('migration_ids') as $migration_id) { + /** @var MigrationInterface $migration */ + $migration = Migration::load($migration_id); + // Fetch the system data at the first opportunity. + if (empty($system_data) && is_a($migration->getSourcePlugin(), '\Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase')) { + $system_data = $migration->getSourcePlugin()->getSystemData(); + } + $template_id = $migration->get('template'); + $source_module = $this->moduleUpgradePaths[$template_id]['source_module']; + $destination_module = $this->moduleUpgradePaths[$template_id]['destination_module']; + $table_data[$source_module][$destination_module][$migration_id] = $migration->label(); + } + 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. + $desc = "The following items will not be upgraded. " . + 'For more information see Upgrading from Drupal 6 or 7 to Drupal 8.'; + $form['missing_module_list_title'] = [ + '#type' => 'item', + '#title' => t('Missing upgrade paths'), + '#description' => $this->t($desc), + ]; + $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' => t('Available upgrade paths'), + ]; + + $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' => t($destination_module), + ]; + } + $form['available_module_list']['module_list'][$source_module] = [ + 'source_module' => ['#plain_text' => $source_module], + 'destination_module' => $destination_details, + ]; + } + $form['counts'] = [ + '#type' => 'item', + '#title' => "", + '#weight' => -15, + ]; + } + if ($rollback) { + $confirm_text = $this->t('Perform rollback'); + } + else { + $confirm_text = $this->t('Perform upgrade'); + } + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = [ + '#type' => 'submit', + '#value' => $confirm_text, + '#button_type' => 'primary', + '#validate' => [], + '#submit' => ['::submitConfirmForm'], + ]; + + $form['actions']['cancel'] = ConfirmFormHelper::buildCancelLink($this, $this->getRequest()); + + // By default, render the form using theme_confirm_form(). + if (!isset($form['#theme'])) { + $form['#theme'] = 'confirm_form'; + } + return $form; + } + + /** + * Credential form submission handler. + * + * @param array $form + * An associative array containing the structure of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. + */ + public function submitConfirmForm(array &$form, FormStateInterface $form_state) { + $storage = $form_state->getStorage(); + if ($storage['upgrade_option'] == static::MIGRATE_UPGRADE_ROLLBACK) { + $query = \Drupal::entityQuery('migration'); + $names = $query->execute(); + + // Order the migrations according to their dependencies. + /** @var MigrationInterface[] $migrations */ + $migrations = \Drupal::entityManager() + ->getStorage('migration') + ->loadMultiple($names); + // 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' => [ + [ + ['Drupal\drupal_upgrade\MigrateUpgradeRunBatch', 'run'], + [array_keys($migrations), 'rollback'] + ], + ], + 'finished' => [ + 'Drupal\drupal_upgrade\MigrateUpgradeRunBatch', + 'finished' + ], + ]; + batch_set($batch); + $form_state->setRedirect('drupal_upgrade.upgrade'); + \Drupal::state()->delete('drupal_upgrade.performed'); + } + else { + $batch = [ + 'title' => $this->t('Running upgrade'), + 'progress_message' => '', + 'operations' => [ + [ + ['Drupal\drupal_upgrade\MigrateUpgradeRunBatch', 'run'], + [$form_state->get('migration_ids'), 'import'] + ], + ], + 'finished' => [ + 'Drupal\drupal_upgrade\MigrateUpgradeRunBatch', + 'finished' + ], + ]; + batch_set($batch); + $form_state->setRedirect(''); + \Drupal::state()->set('drupal_upgrade.performed', REQUEST_TIME); + } + } + + /** + * Returns all supported database driver installer objects. + * + * @return \Drupal\Core\Database\Install\Tasks[] + * An array of available database driver installer objects. + */ + protected function getDatabaseTypes() { + // Make sure the install API is available. + include_once DRUPAL_ROOT . '/core/includes/install.inc'; + return drupal_get_database_types(); + } + + /** + * {@inheritdoc} + */ + public function getQuestion() { + return $this->t('Are you sure?'); + } + + /** + * {@inheritdoc} + */ + public function getCancelUrl() { + return new Url('drupal_upgrade.upgrade'); + } + + /** + * {@inheritdoc} + */ + public function getDescription() { + return $this->t('

Upgrade analysis report

'); + } + + /** + * {@inheritdoc} + */ + public function getConfirmText() { + return $this->t('Perform upgrade'); + } + + /** + * {@inheritdoc} + */ + public function getCancelText() { + return $this->t('Cancel'); + } + + /** + * {@inheritdoc} + */ + public function getFormName() { + return 'confirm'; + } + +} diff --git a/core/modules/drupal_upgrade/src/MigrateMessageCapture.php b/core/modules/drupal_upgrade/src/MigrateMessageCapture.php new file mode 100644 index 0000000..11df8b4 --- /dev/null +++ b/core/modules/drupal_upgrade/src/MigrateMessageCapture.php @@ -0,0 +1,48 @@ +messages[] = $message; + } + + /** + * Clear out any captured messages. + */ + public function clear() { + $this->messages = []; + } + + /** + * Return any captured messages. + * + * @return array + */ + public function getMessages() { + return $this->messages; + } + +} diff --git a/core/modules/drupal_upgrade/src/MigrateUpgradeRunBatch.php b/core/modules/drupal_upgrade/src/MigrateUpgradeRunBatch.php new file mode 100644 index 0000000..f0d5dd5 --- /dev/null +++ b/core/modules/drupal_upgrade/src/MigrateUpgradeRunBatch.php @@ -0,0 +1,332 @@ +addListener(MigrateEvents::POST_ROW_SAVE, + [get_class(), 'onPostRowSave']); + \Drupal::service('event_dispatcher')->addListener(MigrateEvents::MAP_SAVE, + [get_class(), 'onMapSave']); + } + else { + \Drupal::service('event_dispatcher')->addListener(MigrateEvents::POST_ROW_DELETE, + [get_class(), 'onPostRowDelete']); + \Drupal::service('event_dispatcher')->addListener(MigrateEvents::MAP_DELETE, + [get_class(), 'onMapDelete']); + } + static::$maxExecTime = ini_get('max_execution_time'); + if (static::$maxExecTime <= 0) { + static::$maxExecTime = 60; + } + // Set an arbitrary threshold of 3 seconds (e.g., if max_execution_time is + // 45 seconds, we will quit at 42 seconds so a slow item or cleanup + // overhead don't put us over 45). + static::$maxExecTime -= 3; + static::$listenersAdded = TRUE; + } + if (!isset($context['sandbox']['migration_ids'])) { + $context['sandbox']['max'] = count($initial_ids); + $context['sandbox']['current'] = 1; + // migration_ids will be the list of IDs remaining to run. + $context['sandbox']['migration_ids'] = $initial_ids; + $context['sandbox']['messages'] = []; + $context['results']['failures'] = 0; + $context['results']['successes'] = 0; + $context['results']['operation'] = $operation; + } + + $migration_id = reset($context['sandbox']['migration_ids']); + /** @var \Drupal\migrate\Entity\Migration $migration */ + $migration = Migration::load($migration_id); + if ($migration) { + $messages = new MigrateMessageCapture(); + $executable = new MigrateExecutable($migration, $messages); + + $migration_name = $migration->label() ? $migration->label() : $migration_id; + + try { + if ($operation == 'import') { + $migration_status = $executable->import(); + } + else { + $migration_status = $executable->rollback(); + } + } + catch (\Exception $e) { + static::logger()->error($e->getMessage()); + $migration_status = MigrationInterface::RESULT_FAILED; + } + + switch ($migration_status) { + case MigrationInterface::RESULT_COMPLETED: + if ($operation == 'import') { + $singular_message = 'Upgraded @migration (processed 1 item total)'; + $plural_message = 'Upgraded @migration (processed @num_processed items total)'; + } + else { + $singular_message = 'Rolled back @migration (processed 1 item total)'; + $plural_message = 'Rolled back @migration (processed @num_processed items total)'; + $migration->delete(); + } + // @todo: Not quite right (although it will appear to be right most of the time). + // We should instead accumulate per-migration total processed numbers in + // the sandbox. + if ($operation == 'import') { + $processed = $migration->getIdMap()->processedCount(); + } + else { + $processed = static::$numProcessed; + } + $message = \Drupal::translation()->formatPlural( + $processed, $singular_message, $plural_message, + ['@migration' => $migration_name, '@num_processed' => $processed]); + $context['sandbox']['messages'][] = $message; + static::logger()->notice($message); + static::$numProcessed = 0; + $context['results']['successes']++; + break; + + case MigrationInterface::RESULT_INCOMPLETE: + $singular_message = 'Continuing with @migration (processed 1 item)'; + $plural_message = 'Continuing with @migration (processed @num_processed items)'; + $context['sandbox']['messages'][] = \Drupal::translation()->formatPlural( + static::$numProcessed, $singular_message, $plural_message, + ['@migration' => $migration_name, '@num_processed' => static::$numProcessed]); + static::$numProcessed = 0; + break; + + case MigrationInterface::RESULT_STOPPED: + $context['sandbox']['messages'][] = t('Operation stopped by request'); + break; + + case MigrationInterface::RESULT_FAILED: + $context['sandbox']['messages'][] = t('Operation on @migration failed', ['@migration' => $migration_name]); + $context['results']['failures']++; + static::logger()->error('Operation on @migration failed', ['@migration' => $migration_name]); + break; + + case MigrationInterface::RESULT_SKIPPED: + $context['sandbox']['messages'][] = t('Operation on @migration skipped due to unfulfilled dependencies', ['@migration' => $migration_name]); + static::logger()->error('Operation on @migration skipped due to unfulfilled dependencies', ['@migration' => $migration_name]); + break; + + case MigrationInterface::RESULT_DISABLED: + // Skip silently if disabled. + break; + } + + // Unless we're continuing on with this migration, take it off the list. + if ($migration_status != MigrationInterface::RESULT_INCOMPLETE) { + array_shift($context['sandbox']['migration_ids']); + $context['sandbox']['current']++; + } + + // Add and log any captured messages. + foreach ($messages->getMessages() as $message) { + $context['sandbox']['messages'][] = $message; + static::logger()->error($message); + } + + // Only display the last MESSAGE_LENGTH messages, in reverse order. + $message_count = count($context['sandbox']['messages']); + $context['message'] = ''; + for ($index = max(0, $message_count - self::MESSAGE_LENGTH); $index < $message_count; $index++) { + $context['message'] = $context['sandbox']['messages'][$index]. "
\n" . $context['message']; + } + if ($message_count > self::MESSAGE_LENGTH) { + // Indicate there are earlier messages not displayed. + $context['message'] .= '…'; + } + // At the top of the list, display the next one (which will be the one + // that is running while this message is visible). + if (!empty($context['sandbox']['migration_ids'])) { + $migration_id = reset($context['sandbox']['migration_ids']); + $migration = Migration::load($migration_id); + $migration_name = $migration->label() ? $migration->label() : $migration_id; + if ($operation == 'import') { + $message = 'Currently upgrading @migration (@current of @max total tasks)'; + } + else { + $message = 'Currently rolling back @migration (@current of @max total tasks)'; + } + $context['message'] = t($message, + ['@migration' => $migration_name, '@current' => $context['sandbox']['current'], + '@max' => $context['sandbox']['max']]) . "
\n" . $context['message']; + } + } + else { + array_shift($context['sandbox']['migration_ids']); + $context['sandbox']['current']++; + } + + $context['finished'] = 1 - count($context['sandbox']['migration_ids']) / $context['sandbox']['max']; + } + + /** + * A helper method to grab the logger using the drupal_upgrade channel. + * + * @return \Psr\Log\LoggerInterface + * The logger instance. + */ + protected static function logger() { + return \Drupal::logger('drupal_upgrade'); + } + + /** + * Implementation of the Batch API finished method. + */ + public static function finished($success, $results, $operations, $elapsed) { + static::displayResults($results); + } + + /** + * Display counts of success/failures on the migration upgrade complete page. + * + * @param $results + * An array of result data built during the batch. + */ + protected static function displayResults($results) { + $successes = $results['successes']; + $failures = $results['failures']; + $translation = \Drupal::translation(); + + // If we had any successes lot that for the user. + if ($successes > 0) { + if ($results['operation'] == 'import') { + drupal_set_message(t('Completed @count successfully.', ['@count' => $translation->formatPlural($successes, '1 upgrade task', '@count upgrade tasks')])); + } + else { + drupal_set_message(t('Completed @count successfully.', ['@count' => $translation->formatPlural($successes, '1 rollback task', '@count rollback tasks')])); + } + } + + // If we had failures, log them and show the migration failed. + if ($failures > 0) { + if ($results['operation'] == 'import') { + drupal_set_message(t('@count failed', ['@count' => $translation->formatPlural($failures, '1 upgrade', '@count upgrades')]), 'error'); + drupal_set_message(t('Upgrade process not completed'), 'error'); + } + else { + drupal_set_message(t('@count failed', ['@count' => $translation->formatPlural($failures, '1 rollback', '@count rollbacks')]), 'error'); + drupal_set_message(t('Rollback process not completed'), 'error'); + } + } + else { + if ($results['operation'] == 'import') { + // Everything went off without a hitch. We may not have had successes 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')) { + $url = Url::fromRoute('drupal_upgrade.log'); + drupal_set_message(\Drupal::l(t('Review the detailed upgrade log'), $url), $failures ? 'error' : 'status'); + } + } + + /** + * React to item import. + * + * @param \Drupal\migrate\Event\MigratePostRowSaveEvent $event + * The post-save event. + */ + public static function onPostRowSave(MigratePostRowSaveEvent $event) { + // We want to interrupt this batch and start a fresh one. + if ((time() - REQUEST_TIME) > static::$maxExecTime) { + $event->getMigration()->interruptMigration(MigrationInterface::RESULT_INCOMPLETE); + } + } + + /** + * React to item deletion. + * + * @param \Drupal\migrate\Event\MigrateRowDeleteEvent $event + * The post-save event. + */ + public static function onPostRowDelete(MigrateRowDeleteEvent $event) { + // We want to interrupt this batch and start a fresh one. + if ((time() - REQUEST_TIME) > static::$maxExecTime) { + $event->getMigration()->interruptMigration(MigrationInterface::RESULT_INCOMPLETE); + } + } + + /** + * Count up any map save events. + * + * @param \Drupal\migrate\Event\MigrateMapSaveEvent $event + * The map event. + */ + public static function onMapSave(MigrateMapSaveEvent $event) { + static::$numProcessed++; + } + + /** + * Count up any map delete events. + * + * @param \Drupal\migrate\Event\MigrateMapDeleteEvent $event + * The map event. + */ + public static function onMapDelete(MigrateMapDeleteEvent $event) { + static::$numProcessed++; + } + +} diff --git a/core/modules/migrate_drupal/src/MigrationCreationTrait.php b/core/modules/migrate_drupal/src/MigrationCreationTrait.php new file mode 100644 index 0000000..e5fcbc0 --- /dev/null +++ b/core/modules/migrate_drupal/src/MigrationCreationTrait.php @@ -0,0 +1,139 @@ +getLegacyDrupalVersion($connection)) { + throw new \Exception($this->t('Source database does not contain a recognizable Drupal version.')); + } + $database_state['key'] = 'upgrade'; + $database_state['database'] = $database; + $database_state_key = 'migrate_drupal_' . $drupal_version; + \Drupal::state()->set($database_state_key, $database_state); + + $version_tag = 'Drupal ' . $drupal_version; + + $template_storage = \Drupal::service('migrate.template_storage'); + $migration_templates = $template_storage->findTemplatesByTag($version_tag); + foreach ($migration_templates as $id => $template) { + $migration_templates[$id]['source']['database_state_key'] = $database_state_key; + // Configure file migrations so they can find the files. + if ($template['destination']['plugin'] == 'entity:file') { + if ($source_base_path) { + // Make sure we have a single trailing slash. + $source_base_path = rtrim($source_base_path, '/') . '/'; + $migration_templates[$id]['destination']['source_base_path'] = $source_base_path; + } + } + } + + // Let the builder service create our migration configuration entities from + // the templates, expanding them to multiple entities where necessary. + /** @var \Drupal\migrate\MigrationBuilder $builder */ + $builder = \Drupal::service('migrate.migration_builder'); + $migrations = $builder->createMigrations($migration_templates); + $migration_ids = []; + foreach ($migrations as $migration) { + try { + if ($migration->getSourcePlugin() instanceof RequirementsInterface) { + $migration->getSourcePlugin()->checkRequirements(); + } + if ($migration->getDestinationPlugin() instanceof RequirementsInterface) { + $migration->getDestinationPlugin()->checkRequirements(); + } + // Don't try to resave migrations that already exist. + if (!Migration::load($migration->id())) { + $migration->save(); + } + $migration_ids[] = $migration->id(); + } + // Migrations which are not applicable given the source and destination + // site configurations (e.g., what modules are enabled) will be silently + // ignored. + catch (RequirementsException $e) { + } + catch (PluginNotFoundException $e) { + } + } + + // loadMultiple will sort the migrations in dependency order. + return array_keys(Migration::loadMultiple($migration_ids)); + } + + /** + * Determine what version of Drupal the source database contains. + * + * @param \Drupal\Core\Database\Connection $connection + * + * @return int|FALSE + */ + protected function getLegacyDrupalVersion(Connection $connection) { + // Don't assume because a table of that name exists, that it has the columns + // we're querying. Catch exceptions and report that the source database is + // not Drupal. + + // Druppal 5/6/7 can be detected by the schema_version in the system table. + if ($connection->schema()->tableExists('system')) { + try { + $version_string = $connection->query('SELECT schema_version FROM {system} WHERE name = :module', [':module' => 'system']) + ->fetchField(); + if ($version_string && $version_string[0] == '1') { + if ((int) $version_string >= 1000) { + $version_string = '5'; + } + else { + $version_string = FALSE; + } + } + } + catch (\PDOException $e) { + $version_string = FALSE; + } + } + // For Drupal 8 (and we're predicting beyond) the schema version is in the + // key_value store. + elseif ($connection->schema()->tableExists('key_value')) { + $result = $connection->query("SELECT value FROM {key_value} WHERE collection = :system_schema and name = :module", [':system_schema' => 'system.schema', ':module' => 'system'])->fetchField(); + $version_string = unserialize($result); + } + else { + $version_string = FALSE; + } + + return $version_string ? substr($version_string, 0, 1) : FALSE; + } + +}