From 537c972041d86b8799e2bf3669e67f3da221e73d Mon Sep 17 00:00:00 2001 From: godotislate <15754-godotislate@users.noreply.drupalcode.org> Date: Tue, 7 Jan 2025 14:59:24 +0000 Subject: [PATCH] Issue #3413894 by b2f, godotislate, heddn: Revert requirement that IDs not include spaces --- src/Plugin/migrate/source/CSV.php | 11 +------ .../Plugin/migrate/source/CSVUnitTest.php | 29 ------------------- 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/src/Plugin/migrate/source/CSV.php b/src/Plugin/migrate/source/CSV.php index 7cd2679..eef4398 100644 --- a/src/Plugin/migrate/source/CSV.php +++ b/src/Plugin/migrate/source/CSV.php @@ -14,10 +14,7 @@ use League\Csv\Reader; * Available configuration options: * - path: Path to the CSV file. File streams are supported. Use /dev/null to * get an empty source (useful for migration_lookup). - * - ids: Array of column names that uniquely identify each record. Column - * names used as IDs can only contain letters (uppercase and lowercase), - * numbers (0-9), and underscores. No spaces or other special characters - * are allowed. + * - ids: Array of column names that uniquely identify each record. * - header_offset: (optional) The record to be used as the CSV header and the * thereby each record's field name. Defaults to 0 and because records are * zero indexed. Can be set to null to indicate no header record. @@ -122,12 +119,6 @@ class CSV extends SourcePluginBase implements ConfigurableInterface { if ($this->configuration['ids'] !== array_unique(array_filter($this->configuration['ids'], 'is_string'))) { throw new \InvalidArgumentException('The ids must a flat array with unique string values.'); } - foreach ($this->configuration['ids'] as $id) { - if (!preg_match('/^\w+$/', $id)) { - throw new \InvalidArgumentException(sprintf('The id (%s) must only include word characters a-z, A-Z, 0-9, including _ (underscore).', $id)); - } - } - // CSV character control characters must be exactly 1 character. foreach (['delimiter', 'enclosure', 'escape'] as $character) { if (1 !== strlen($this->configuration[$character])) { diff --git a/tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php b/tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php index e8d38e9..691cee2 100644 --- a/tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php +++ b/tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php @@ -118,35 +118,6 @@ EOD; new CSV($configuration, $this->pluginId, $this->pluginDefinition, $this->migration); } - /** - * Tests that valid IDs are validated. - */ - public function testValidIds(): void { - $configuration = [ - 'path' => $this->standardCharsPath, - 'ids' => [ - 'asdfASDF_', - ], - ]; - $csv = new CSV($configuration, $this->pluginId, $this->pluginDefinition, $this->migration); - $this->assertInstanceOf(CSV::class, $csv); - } - - /** - * Tests invalid IDs are validated. - */ - public function testInvalidIds(): void { - $configuration = [ - 'path' => $this->standardCharsPath, - 'ids' => [ - 'asdfASDF_-', - ], - ]; - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('The id (asdfASDF_-) must only include word characters a-z, A-Z, 0-9, including _ (underscore).'); - new CSV($configuration, $this->pluginId, $this->pluginDefinition, $this->migration); - } - /** * Tests that toString functions as expected. * -- GitLab