diff --git a/core/modules/file/migrations/d7_file.yml b/core/modules/file/migrations/d7_file.yml index 3ead3e5ed436483849a164916757c9559e43bb2f..4ad4e941e795bbc108ead1730ead5cfef3c85a1e 100644 --- a/core/modules/file/migrations/d7_file.yml +++ b/core/modules/file/migrations/d7_file.yml @@ -19,7 +19,14 @@ 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 + # File entity module uses file_managed.filename as the entity title, while + # Drupal 8 expects this to be an actual file name. Therefore, extract the + # filename from the uri field. Otherwise, the file will migrate but form + # validation won't pass when editing it. + filename: + plugin: callback + callable: basename + source: uri source_full_path: - plugin: concat diff --git a/core/modules/file/migrations/d7_file_private.yml b/core/modules/file/migrations/d7_file_private.yml index e0e1705d75448b2b5778ab3a4a69821848ca4dd4..0ac986c20f800623e140fa8a3f6eae3d1c836ee0 100644 --- a/core/modules/file/migrations/d7_file_private.yml +++ b/core/modules/file/migrations/d7_file_private.yml @@ -17,7 +17,14 @@ 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 + # File entity module uses file_managed.filename as the entity title, while + # Drupal 8 expects this to be an actual file name. Therefore, extract the + # filename from the uri field. Otherwise, the file will migrate but form + # validation won't pass when editing it. + filename: + plugin: callback + callable: basename + source: uri source_full_path: - plugin: concat diff --git a/core/modules/file/tests/modules/file_test_get_ids/migrations/d7_file_used.yml b/core/modules/file/tests/modules/file_test_get_ids/migrations/d7_file_used.yml index 93d0300166f84090c4c91c89e01eed1208370deb..9692bcd1f21a96415d3905e8521c122510491819 100644 --- a/core/modules/file/tests/modules/file_test_get_ids/migrations/d7_file_used.yml +++ b/core/modules/file/tests/modules/file_test_get_ids/migrations/d7_file_used.yml @@ -9,7 +9,14 @@ source: source_base_path: '' process: fid: fid - filename: filename + # File entity module uses file_managed.filename as the entity title, while + # Drupal 8 expects this to be an actual file name. Therefore, extract the + # filename from the uri field. Otherwise, the file will migrate but form + # validation won't pass when editing it. + filename: + plugin: callback + callable: basename + source: uri source_full_path: - plugin: concat diff --git a/core/modules/file/tests/src/Kernel/Migrate/d7/MigrateFileTest.php b/core/modules/file/tests/src/Kernel/Migrate/d7/MigrateFileTest.php index fcfe5adcfe6f92edf6763fdd29cc6f82c1d35c9e..f427e7a0ac6f350a5fcc7afb4a4eb0abb466520e 100644 --- a/core/modules/file/tests/src/Kernel/Migrate/d7/MigrateFileTest.php +++ b/core/modules/file/tests/src/Kernel/Migrate/d7/MigrateFileTest.php @@ -24,6 +24,10 @@ class MigrateFileTest extends MigrateDrupal7TestBase { */ protected function setUp(): void { parent::setUp(); + $this->sourceDatabase->update('file_managed') + ->fields(['filename' => 'this can have spaces in it']) + ->condition('fid', 1) + ->execute(); $this->fileMigrationSetup(); } 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 f9ecfc7fb6ed08f0905fdf06f8b1727a53479533..8fc020d29914143bbf88aeb52e5c7f4b6747b6f6 100644 --- a/core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileTest.php +++ b/core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileTest.php @@ -24,6 +24,10 @@ class MigratePrivateFileTest extends MigrateDrupal7TestBase { */ protected function setUp(): void { parent::setUp(); + $this->sourceDatabase->update('file_managed') + ->fields(['filename' => 'this can have spaces in it']) + ->condition('fid', 3) + ->execute(); $this->setSetting('file_private_path', $this->container->getParameter('site.path') . '/private'); $this->fileMigrationSetup(); }