MDL-37774 Make moodle1_file_manager::migrate_directory() support trailing slash in...
[moodle.git] / backup / converter / moodle1 / lib.php
index d91e2f2..8f7ec30 100644 (file)
@@ -1279,6 +1279,12 @@ class moodle1_file_manager implements loggable {
      */
     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();
         }