Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
d2edf3eb
Unverified
Commit
d2edf3eb
authored
Sep 29, 2020
by
larowlan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#3160015
by quietone, mikelutz: Don't remove all slashes from filepath in file.php
(cherry picked from commit
6e1d970a
)
parent
bd3795dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
core/modules/file/src/Plugin/migrate/source/d7/File.php
core/modules/file/src/Plugin/migrate/source/d7/File.php
+1
-1
core/modules/file/tests/src/Kernel/Plugin/migrate/source/d7/FileTest.php
...le/tests/src/Kernel/Plugin/migrate/source/d7/FileTest.php
+30
-0
No files found.
core/modules/file/src/Plugin/migrate/source/d7/File.php
View file @
d2edf3eb
...
...
@@ -88,7 +88,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
// the source_base_path in order to make them all relative.
$path
=
str
_replace
(
$this
->
configuration
[
'constants'
][
'source_base_path'
]
,
NULL
,
$path
);
$path
=
preg
_replace
(
'#'
.
preg_quote
(
$this
->
configuration
[
'constants'
][
'source_base_path'
]
)
.
'#'
,
''
,
$path
,
1
);
$row
->
setSourceProperty
(
'filepath'
,
$path
);
return
parent
::
prepareRow
(
$row
);
}
...
...
core/modules/file/tests/src/Kernel/Plugin/migrate/source/d7/FileTest.php
View file @
d2edf3eb
...
...
@@ -158,6 +158,36 @@ public function providerSource() {
'scheme'
=>
'public'
,
];
// Test getting only private files with absolute file private path.
$tests
[
3
][
'source_data'
]
=
$tests
[
0
][
'source_data'
];
$tests
[
3
][
'source_data'
][
'variable'
][
1
]
=
[
'name'
=>
'file_private_path'
,
'value'
=>
serialize
(
'/home/lillian/subdomains/u2/u2-private-files'
),
];
$tests
[
3
][
'expected_data'
]
=
[
[
'fid'
=>
'1'
,
'uid'
=>
'1'
,
'filename'
=>
'cube.jpeg'
,
'uri'
=>
'private://cube.jpeg'
,
'filemime'
=>
'image/jpeg'
,
'filesize'
=>
'3620'
,
'status'
=>
'1'
,
'timestamp'
=>
'1421727515'
,
'filepath'
=>
'home/lillian/subdomains/u2/u2-private-files/cube.jpeg'
,
],
];
// Do an automatic count.
$tests
[
3
][
'expected_count'
]
=
NULL
;
// Set up plugin configuration.
$tests
[
3
][
'configuration'
]
=
[
'constants'
=>
[
'source_base_path'
=>
'/'
,
],
'scheme'
=>
'private'
,
];
return
$tests
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment