diff --git a/core/modules/file/src/Plugin/migrate/source/d7/File.php b/core/modules/file/src/Plugin/migrate/source/d7/File.php index a4a500b..6752575 100644 --- a/core/modules/file/src/Plugin/migrate/source/d7/File.php +++ b/core/modules/file/src/Plugin/migrate/source/d7/File.php @@ -84,7 +84,7 @@ public function prepareRow(Row $row) { // 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 if (isset($this->configuration['constants']['source_file_private_path'])) { - $path = str_replace($this->configuration['constants']['source_file_private_path'], NULL, $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); diff --git a/core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileTest.php b/core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileTest.php index 848ade4..076c1fa 100644 --- a/core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileTest.php +++ b/core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileTest.php @@ -2,7 +2,7 @@ namespace Drupal\Tests\file\Kernel\Migrate\d7; -use Drupal\Core\StreamWrapper\StreamWrapperInterface; +use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\file\Entity\File; use Drupal\file\FileInterface; use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase; @@ -23,11 +23,10 @@ protected function setUp() { parent::setUp(); $this->setSetting('file_private_path', 'sites/default/private'); $this->installEntitySchema('file'); - $this->container->get('stream_wrapper_manager')->registerWrapper('private', 'Drupal\Core\StreamWrapper\PrivateStream', StreamWrapperInterface::NORMAL); - $fs = \Drupal::service('file_system'); + $fs = $this->container->get('file_system'); // Put test file in the source directory. - file_put_contents('private://sites/default/private/Babylon5.txt', str_repeat('*', 3)); + file_put_contents('private://Babylon5.txt', str_repeat('*', 3)); /** @var \Drupal\migrate\Plugin\Migration $migration */ $migration = $this->getMigration('d7_file_private'); @@ -40,6 +39,15 @@ protected function setUp() { } /** + * {@inheritdoc} + */ + public function register(ContainerBuilder $container) { + parent::register($container); + $container->register('stream_wrapper.private', 'Drupal\Core\StreamWrapper\PrivateStream') + ->addTag('stream_wrapper', ['scheme' => 'private']); + } + + /** * Tests a single file entity. * * @param int $id