From 4eef1c2e142def8464498019ec7249d98df9ef70 Mon Sep 17 00:00:00 2001 From: Eric Merrill Date: Fri, 20 Apr 2012 10:08:48 -0400 Subject: [PATCH] MDL-32012 resource: flaw in restore from moodle 1.9 backups --- mod/resource/backup/moodle1/lib.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mod/resource/backup/moodle1/lib.php b/mod/resource/backup/moodle1/lib.php index 8dcc59673e2..d61cbd8f029 100644 --- a/mod/resource/backup/moodle1/lib.php +++ b/mod/resource/backup/moodle1/lib.php @@ -192,8 +192,17 @@ class moodle1_mod_resource_handler extends moodle1_mod_handler { } $this->fileman->filearea = 'content'; $this->fileman->itemid = 0; + + // Rebuild the file path. + $curfilepath = '/'; + if ($reference) { + $curfilepath = pathinfo('/'.$reference, PATHINFO_DIRNAME); + if ($curfilepath != '/') { + $curfilepath .= '/'; + } + } try { - $this->fileman->migrate_file('course_files/'.$reference, '/', null, 1); + $this->fileman->migrate_file('course_files/'.$reference, $curfilepath, null, 1); } catch (moodle1_convert_exception $e) { // the file probably does not exist $this->log('error migrating the resource main file', backup::LOG_WARNING, 'course_files/'.$reference);