From a7b872612179f7dfdbe5ae88c5ae08925593e655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Fri, 8 Feb 2013 11:45:24 +0100 Subject: [PATCH] MDL-37774 Make moodle1_file_manager::migrate_directory() support trailing 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. --- backup/converter/moodle1/lib.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backup/converter/moodle1/lib.php b/backup/converter/moodle1/lib.php index 29521d6016f..29f004d1ffe 100644 --- a/backup/converter/moodle1/lib.php +++ b/backup/converter/moodle1/lib.php @@ -1278,6 +1278,11 @@ class moodle1_file_manager implements loggable { */ public function migrate_directory($rootpath, $relpath='/') { + // Check the trailing slash in the $rootpath + if (substr($rootpath, -1) === '/') { + $rootpath = substr($rootpath, 0, strlen($rootpath) - 1); + } + if (!file_exists($this->basepath.'/'.$rootpath.$relpath)) { return array(); }