Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-37774 Make moodle1_file_manager::migrate_directory() support trai…

…ling slash in rootpath

As the $rootpath is concatenated with the $relpath, we would end with a
path like course_files//file.txt. Such a path is detected as not-valid
later and an error would be thrown.

So the patch makes sure that the trailing slash is cut off and a
debugging for the developer is displayed.
  • Loading branch information...
commit d0530ed4448d8c7abc03f1f4b0c380ecff66f16b 1 parent 86083f9
@mudrd8mz mudrd8mz authored
Showing with 6 additions and 0 deletions.
  1. +6 −0 backup/converter/moodle1/lib.php
View
6 backup/converter/moodle1/lib.php
@@ -1279,6 +1279,12 @@ public function migrate_file($sourcepath, $filepath = '/', $filename = null, $so
*/
public function migrate_directory($rootpath, $relpath='/') {
+ // Check the trailing slash in the $rootpath
+ if (substr($rootpath, -1) === '/') {
+ debugging('moodle1_file_manager::migrate_directory() expects $rootpath without the trailing slash', DEBUG_DEVELOPER);
+ $rootpath = substr($rootpath, 0, strlen($rootpath) - 1);
+ }
+
if (!file_exists($this->basepath.'/'.$rootpath.$relpath)) {
return array();
}
Please sign in to comment.
Something went wrong with that request. Please try again.