Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
migrate_source_csv
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
migrate_source_csv
Commits
537c9720
Commit
537c9720
authored
2 months ago
by
godotislate
Committed by
Lucas Hedding
2 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3413894
by b2f, godotislate, heddn: Revert requirement that IDs not include spaces
parent
24c0986b
Branches
8.x-3.x
No related tags found
1 merge request
!8
Revert "Issue #3379184 by dinarcon, heddn: Document that source IDs can only...
Pipeline
#388728
passed
2 months ago
Stage: build
Stage: validate
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Plugin/migrate/source/CSV.php
+1
-10
1 addition, 10 deletions
src/Plugin/migrate/source/CSV.php
tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php
+0
-29
0 additions, 29 deletions
tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php
with
1 addition
and
39 deletions
src/Plugin/migrate/source/CSV.php
+
1
−
10
View file @
537c9720
...
...
@@ -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
]))
{
...
...
This diff is collapsed.
Click to expand it.
tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php
+
0
−
29
View file @
537c9720
...
...
@@ -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.
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment