diff --git a/core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php b/core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php index 8d9fd8f..5d60960 100644 --- a/core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php +++ b/core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php @@ -105,6 +105,7 @@ public static function run($initial_ids, $config, &$context) { if ($definition['destination']['plugin'] === 'entity:file') { // Make sure we have a single trailing slash. $configuration['source']['constants']['source_base_path'] = rtrim($config['source_base_path'], '/') . '/'; + $configuration['source']['constants']['source_private_file_path'] = rtrim($config['source_private_file_path'], '/') . '/'; } /** @var \Drupal\migrate\Plugin\Migration $migration */ diff --git a/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php index 90b0b61..2062b61 100644 --- a/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php +++ b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php @@ -854,6 +854,15 @@ public function buildCredentialForm(array $form, FormStateInterface $form_state) $default_options = []; + + $form['version'] = [ + '#type' => 'radios', + '#default_value' => 6, + '#title' => $this->t('Drupal version of the source site'), + '#options' => [6 => t('Drupal 6'), 7 => t('Drupal 7')], + '#required' => TRUE, + ]; + $form['database'] = [ '#type' => 'details', '#title' => $this->t('Source database'), @@ -913,6 +922,21 @@ 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).'), ]; + $form['source']['source_private_file_path'] = [ + '#type' => 'textfield', + '#title' => $this->t('Private file directory'), + '#default_value' => '', + '#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), or your site address (for example http://example.com).'), + '#states' => [ + 'invisible' => [ + ':input[name="version"]' => ['value' => 6], + ], + 'visible' => [ + ':input[name="version"]' => ['value' => 7], + ], + ], + ]; + $form['actions'] = ['#type' => 'actions']; $form['actions']['save'] = [ '#type' => 'submit', @@ -961,6 +985,12 @@ public function validateCredentialForm(array &$form, FormStateInterface $form_st if (!$version) { $form_state->setErrorByName($database['driver'] . '][0', $this->t('Source database does not contain a recognizable Drupal version.')); } + elseif ($version != $form_state->getValue('version')) { + $form_state->setErrorByName($database['driver'] . '][0', $this->t('Source database is Drupal version @version but version @selected was selected.', [ + '@version' => $version, + '@selected' => $form_state->getValue('version'), + ])); + } else { $this->createDatabaseStateSettings($database, $version); $migrations = $this->getMigrations('migrate_drupal_' . $version, $version); @@ -978,6 +1008,7 @@ public function validateCredentialForm(array &$form, FormStateInterface $form_st // Store the retrieved migration IDs in form storage. $form_state->set('migrations', $migration_array); $form_state->set('source_base_path', $form_state->getValue('source_base_path')); + $form_state->set('source_private_file_path', $form_state->getValue('source_private_file_path')); // Store the retrived system data in form storage. $form_state->set('system_data', $system_data); @@ -1126,6 +1157,7 @@ public function submitConfirmForm(array &$form, FormStateInterface $form_state) $migrations = $storage['migrations']; $config['source_base_path'] = $storage['source_base_path']; + $config['source_private_file_path'] = $storage['source_private_file_path']; $batch = [ 'title' => $this->t('Running upgrade'), 'progress_message' => '', diff --git a/core/modules/migrate_drupal_ui/src/Tests/MigrateUpgradeTestBase.php b/core/modules/migrate_drupal_ui/src/Tests/MigrateUpgradeTestBase.php index c139291..b0a9cc9 100644 --- a/core/modules/migrate_drupal_ui/src/Tests/MigrateUpgradeTestBase.php +++ b/core/modules/migrate_drupal_ui/src/Tests/MigrateUpgradeTestBase.php @@ -121,6 +121,8 @@ protected function testMigrateUpgrade() { $edit = [ $driver => $connection_options, 'source_base_path' => $this->getSourceBasePath(), + 'source_private_file_path' => $this->getSourcePrivateFilePath(), + 'version' => $this->getSourceDrupalVersion(), ]; if (count($drivers) !== 1) { $edit['driver'] = $driver; @@ -186,6 +188,22 @@ protected function testMigrateUpgrade() { abstract protected function getSourceBasePath(); /** + * Gets the source base path for the concrete test. + * + * @return string + * The source base path. + */ + abstract protected function getSourcePrivateFilePath(); + + /** + * Gets the source base path for the concrete test. + * + * @return string + * The source base path. + */ + abstract protected function getSourceDrupalVersion(); + + /** * Gets the expected number of entities per entity type after migration. * * @return int[] diff --git a/core/modules/migrate_drupal_ui/src/Tests/d6/MigrateUpgrade6Test.php b/core/modules/migrate_drupal_ui/src/Tests/d6/MigrateUpgrade6Test.php index 50829f0..b446bcb 100644 --- a/core/modules/migrate_drupal_ui/src/Tests/d6/MigrateUpgrade6Test.php +++ b/core/modules/migrate_drupal_ui/src/Tests/d6/MigrateUpgrade6Test.php @@ -32,6 +32,20 @@ protected function getSourceBasePath() { /** * {@inheritdoc} */ + protected function getSourcePrivateFilePath() { + return ''; + } + + /** + * {@inheritdoc} + */ + protected function getSourceDrupalVersion() { + return 6; + } + + /** + * {@inheritdoc} + */ protected function getEntityCounts() { return [ 'block' => 30, diff --git a/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php b/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php index 77bc2ab..657ac17 100644 --- a/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php +++ b/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php @@ -32,6 +32,20 @@ protected function getSourceBasePath() { /** * {@inheritdoc} */ + protected function getSourcePrivateFilePath() { + return __DIR__ . '/files'; + } + + /** + * {@inheritdoc} + */ + protected function getSourceDrupalVersion() { + return 7; + } + + /** + * {@inheritdoc} + */ protected function getEntityCounts() { return [ 'block' => 25,