Loading core/modules/file/src/Plugin/migrate/source/d7/File.php +1 −1 Original line number Diff line number Diff line Loading @@ -87,7 +87,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); } Loading core/modules/file/tests/src/Kernel/Plugin/migrate/source/d7/FileTest.php +30 −0 Original line number Diff line number Diff line Loading @@ -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; } Loading Loading
core/modules/file/src/Plugin/migrate/source/d7/File.php +1 −1 Original line number Diff line number Diff line Loading @@ -87,7 +87,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); } Loading
core/modules/file/tests/src/Kernel/Plugin/migrate/source/d7/FileTest.php +30 −0 Original line number Diff line number Diff line Loading @@ -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; } Loading