diff -u b/core/modules/file/migration_templates/d7_file_private.yml b/core/modules/file/migration_templates/d7_file_private.yml --- b/core/modules/file/migration_templates/d7_file_private.yml +++ b/core/modules/file/migration_templates/d7_file_private.yml @@ -6,27 +6,27 @@ plugin: d7_file scheme: private constants: - # source_file_private_path must be set by the tool configuring this migration. + # source_full_path must be set by the tool configuring this migration. # It represents the fully qualified path relative to which uris in the files # table are specified, and must end with a /. See source_full_path # configuration in this migration's process pipeline as an example. - source_file_private_path: '' + source_full_path: '' process: # If you are using this file to build a custom migration consider removing # the fid field to allow incremental migrations. fid: fid filename: filename - source_file_private_full_path: + source_full_path: - plugin: concat delimiter: / source: - - constants/source_file_private_path + - constants/source_full_path - filepath uri: plugin: file_copy source: - - '@source_file_private_full_path' + - '@source_full_path' - uri filemime: filemime # filesize is dynamically computed when file entities are saved, so there is reverted: --- b/core/modules/file/src/Plugin/migrate/source/d7/File.php +++ a/core/modules/file/src/Plugin/migrate/source/d7/File.php @@ -83,12 +83,8 @@ $path = str_replace(['public:/', 'private:/', 'temporary:/'], [$this->publicPath, $this->privatePath, $this->temporaryPath], $row->getSourceProperty('uri')); // At this point, $path could be an absolute path or a relative path, // depending on how the scheme's variable was set. So we need to shear out + // the source_base_path in order to make them all relative. + $path = str_replace($this->configuration['constants']['source_base_path'], NULL, $path); - if (isset($this->configuration['constants']['source_file_private_path'])) { - $path = str_replace($this->configuration['constants']['source_file_private_path'], NULL, realpath($path)); - } - else { - $path = str_replace($this->configuration['constants']['source_base_path'], NULL, $path); - } $row->setSourceProperty('filepath', $path); return parent::prepareRow($row); } diff -u b/core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileTest.php b/core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileTest.php --- b/core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileTest.php +++ b/core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileTest.php @@ -35,7 +35,7 @@ // Set the source plugin's source_file_private_path configuration value, // which would normally be set by the user running the migration. $source = $migration->getSourceConfiguration(); - $source['constants']['source_file_private_path'] = $fs->realpath('private://'); + $source['constants']['source_base_path'] = $fs->realpath('private://'); $migration->set('source', $source); $this->executeMigration($migration); } diff -u b/core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php b/core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php --- b/core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php +++ b/core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php @@ -104,8 +104,10 @@ // @todo Find a way to avoid this in https://www.drupal.org/node/2804611. if ($definition['destination']['plugin'] === 'entity:file') { // Make sure we have a single trailing slash. + if ($definition['source']['plugin'] === 'd7_file_private') { + $configuration['source']['constants']['source_base_path'] = rtrim($config['source_private_file_path'], '/') . '/'; + } $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 -u b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php --- b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php +++ b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php @@ -1049,8 +1049,6 @@ // Store the retrieved migration IDs in form storage. $form_state->set('migrations', $migration_array); - $form_state->set('version', $form_state->getValue('version')); - $form_state->set('d6_source_base_path', $form_state->getValue('d6_source_base_path')); $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')); @@ -1200,13 +1198,7 @@ $storage = $form_state->getStorage(); $migrations = $storage['migrations']; - if ($storage['version'] == '6') { - $config['source_base_path'] = $storage['d6_source_base_path']; - } - else { - $config['source_base_path'] = $storage['source_base_path']; - } - $config['source_private_file_path'] = $storage['source_private_file_path']; + $config['source_base_path'] = $storage['source_base_path']; $batch = [ 'title' => $this->t('Running upgrade'), 'progress_message' => '', diff -u b/core/modules/migrate_drupal_ui/src/Tests/MigrateUpgradeTestBase.php b/core/modules/migrate_drupal_ui/src/Tests/MigrateUpgradeTestBase.php --- b/core/modules/migrate_drupal_ui/src/Tests/MigrateUpgradeTestBase.php +++ b/core/modules/migrate_drupal_ui/src/Tests/MigrateUpgradeTestBase.php @@ -127,16 +127,11 @@ $drivers = drupal_get_database_types(); $form = $drivers[$driver]->getFormOptions($connection_options); $connection_options = array_intersect_key($connection_options, $form + $form['advanced_options']); - $version = $this->getSourceDrupalVersion(); $edit = [ $driver => $connection_options, 'source_base_path' => $this->getSourceBasePath(), - 'source_private_file_path' => $this->getSourcePrivateFilePath(), - 'version' => $version, + 'source_private_file_path' => $this->getSourceBasePath(), ]; - if ($version == 6) { - $edit['d6_source_base_path'] = $this->getSourceBasePath(); - } if (count($drivers) !== 1) { $edit['driver'] = $driver; } @@ -203,22 +198,6 @@ 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[] reverted: --- b/core/modules/migrate_drupal_ui/src/Tests/d6/MigrateUpgrade6Test.php +++ a/core/modules/migrate_drupal_ui/src/Tests/d6/MigrateUpgrade6Test.php @@ -32,20 +32,6 @@ /** * {@inheritdoc} */ - protected function getSourcePrivateFilePath() { - return ''; - } - - /** - * {@inheritdoc} - */ - protected function getSourceDrupalVersion() { - return 6; - } - - /** - * {@inheritdoc} - */ protected function getEntityCounts() { return [ 'aggregator_item' => 1, diff -u b/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php b/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php --- b/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php +++ b/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php @@ -33,19 +33,6 @@ protected function getSourceBasePath() { return __DIR__ . '/files'; } - /** - * {@inheritdoc} - */ - protected function getSourcePrivateFilePath() { - return ''; - } - - /** - * {@inheritdoc} - */ - protected function getSourceDrupalVersion() { - return 7; - } /** * {@inheritdoc} @@ -65,7 +52,7 @@ 'editor' => 2, 'field_config' => 53, 'field_storage_config' => 40, - 'file' => 3, + 'file' => 2, 'filter_format' => 7, 'image_style' => 6, 'language_content_settings' => 2,