diff -u b/core/modules/file/src/Plugin/migrate/destination/EntityFile.php b/core/modules/file/src/Plugin/migrate/destination/EntityFile.php --- b/core/modules/file/src/Plugin/migrate/destination/EntityFile.php +++ b/core/modules/file/src/Plugin/migrate/destination/EntityFile.php @@ -3,11 +3,7 @@ namespace Drupal\file\Plugin\migrate\destination; use Drupal\Component\Utility\Unicode; -use Drupal\Core\Entity\EntityManagerInterface; -use Drupal\Core\Entity\EntityStorageInterface; -use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Field\Plugin\Field\FieldType\UriItem; -use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Row; use Drupal\migrate\MigrateException; use Drupal\migrate\Plugin\migrate\destination\EntityContentBase; @@ -32,6 +28,9 @@ // By default the entity key (fid) would be used, but we want to make sure // we're loading the matching URI. $destination = $row->getDestinationProperty('uri'); + if (empty($destination)) { + throw new MigrateException('Destination property uri not provided'); + } $entity = $this->storage->loadByProperties(['uri' => $destination]); if ($entity) { return reset($entity); diff -u b/core/modules/file/tests/src/Kernel/Migrate/d6/FileMigrationTestTrait.php b/core/modules/file/tests/src/Kernel/Migrate/d6/FileMigrationTestTrait.php --- b/core/modules/file/tests/src/Kernel/Migrate/d6/FileMigrationTestTrait.php +++ b/core/modules/file/tests/src/Kernel/Migrate/d6/FileMigrationTestTrait.php @@ -21,7 +21,7 @@ /** * {@inheritdoc} */ - protected function processMigration(MigrationInterface $migration) { + protected function prepareMigration(MigrationInterface $migration) { // File migrations need a source_base_path. // @see MigrateUpgradeRunBatch::run $destination = $migration->getDestinationConfiguration(); reverted: --- b/core/modules/file/tests/src/Unit/Plugin/migrate/process/UrlEncodeTest.php +++ /dev/null @@ -1,65 +0,0 @@ - 'test', - ]; - - /** - * The data provider for testing URL encoding scenarios. - * - * @return array - * An array of URLs to test. - */ - public function urlDataProvider() { - return [ - 'A URL with no characters requiring encoding' => ['http://example.com/normal_url.html', 'http://example.com/normal_url.html'], - 'The definitive use case - encoding spaces in URLs' => ['http://example.com/url with spaces.html', 'http://example.com/url%20with%20spaces.html'], - 'Local filespecs without spaces should not be transformed' => ['/tmp/normal.txt', '/tmp/normal.txt'], - 'Local filespecs with spaces should not be transformed' => ['/tmp/with spaces.txt', '/tmp/with spaces.txt'], - 'Make sure URL characters (:, ?, &) are not encoded but others are.' => ['https://example.com/?a=b@c&d=e+f%', 'https://example.com/?a%3Db%40c&d%3De%2Bf%25'], - ]; - } - - /** - * Cover various encoding scenarios. - * @dataProvider urlDataProvider - */ - public function testUrls($input, $output) { - $this->assertEquals($output, $this->doTransform($input)); - } - - /** - * Perform the urlencode process plugin over the given value. - * - * @param string $value - * URL to be encoded. - * - * @return string - * Encoded URL. - */ - protected function doTransform($value) { - $executable = new MigrateExecutable($this->getMigration(), new MigrateMessage()); - $row = new Row([], []); - - return (new UrlEncode([], 'urlencode', [])) - ->transform($value, $executable, $row, 'foobaz'); - } - -} diff -u b/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php b/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php --- b/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php +++ b/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php @@ -76,7 +76,7 @@ * {@inheritdoc} */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { - // If we're stubbing a file entity, return a uri of NULL so it will get + // If we're stubbing a file entity, return a URI of NULL so it will get // stubbed by the general process. if ($row->isStub()) { return NULL; @@ -94,13 +94,14 @@ } $replace = $this->getOverwriteMode(); - // We attempt the copy/move first to avoid calling file_prepare_directory() any - // more than absolutely necessary. + // We attempt the copy/move first to avoid calling file_prepare_directory() + // any more than absolutely necessary. $final_destination = $this->writeFile($source, $destination, $replace); if ($final_destination) { return $final_destination; } - // If writeFile didn't work, make sure there's a writable directory in place. + // If writeFile didn't work, make sure there's a writable directory in + // place. $dir = $this->getDirectory($destination); if (!file_prepare_directory($dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) { throw new MigrateException("Could not create or write to directory '$dir'"); diff -u b/core/modules/migrate/src/Plugin/migrate/process/UrlEncode.php b/core/modules/migrate/src/Plugin/migrate/process/UrlEncode.php --- b/core/modules/migrate/src/Plugin/migrate/process/UrlEncode.php +++ b/core/modules/migrate/src/Plugin/migrate/process/UrlEncode.php @@ -52,7 +52,7 @@ $parsed_url[$parsed_url_key] = $urlencoded_parsed_url_value; } } - $value = (string)Uri::fromParts($parsed_url); + $value = (string) Uri::fromParts($parsed_url); } return $value; } diff -u b/core/modules/migrate/tests/src/Kernel/MigrateTestBase.php b/core/modules/migrate/tests/src/Kernel/MigrateTestBase.php --- b/core/modules/migrate/tests/src/Kernel/MigrateTestBase.php +++ b/core/modules/migrate/tests/src/Kernel/MigrateTestBase.php @@ -144,7 +144,7 @@ * @param \Drupal\migrate\Plugin\MigrationInterface $migration * The migration to execute. */ - protected function processMigration(MigrationInterface $migration) { + protected function prepareMigration(MigrationInterface $migration) { // Default implementation for test classes not requiring modification. } @@ -165,7 +165,7 @@ static::migrateDumpAlter($this); } - $this->processMigration($this->migration); + $this->prepareMigration($this->migration); (new MigrateExecutable($this->migration, $this))->import(); } diff -u b/core/modules/migrate/tests/src/Unit/process/CopyFileTest.php b/core/modules/migrate/tests/src/Unit/process/CopyFileTest.php --- b/core/modules/migrate/tests/src/Unit/process/CopyFileTest.php +++ b/core/modules/migrate/tests/src/Unit/process/CopyFileTest.php @@ -22,7 +22,9 @@ public static $modules = ['system']; /** - * @var FileSystemInterface + * The file system service. + * + * @var \Drupal\Core\File\FileSystemInterface */ protected $fileSystem;