From f1a22c4a1bb3629f3c2f3de3201ba3e2e19389b7 Mon Sep 17 00:00:00 2001 From: Michael Spall Date: Fri, 30 Nov 2018 09:10:51 -0700 Subject: [PATCH] MDL-64290 backup imscc: Use correct tempdir for imscc restore Use configured temp directory $CFG->tempdir instead of hard coded $CFG->dataroot . '/temp/backup/' Remove unused variable, $CFG --- backup/converter/imscc1/lib.php | 7 ++++--- backup/converter/imscc11/lib.php | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/backup/converter/imscc1/lib.php b/backup/converter/imscc1/lib.php index 10476d01752..ed4d811b902 100644 --- a/backup/converter/imscc1/lib.php +++ b/backup/converter/imscc1/lib.php @@ -37,9 +37,10 @@ class imscc1_converter extends base_converter { * @return null|string backup::FORMAT_IMSCC1 if the Common Cartridge 1.0 is detected, null otherwise */ public static function detect_format($tempdir) { - global $CFG; - - $filepath = $CFG->dataroot . '/temp/backup/' . $tempdir; + $filepath = make_backup_temp_directory($tempdir, false); + if (!is_dir($filepath)) { + throw new convert_helper_exception('tmp_backup_directory_not_found', $filepath); + } $manifest = cc2moodle::get_manifest($filepath); if (!empty($manifest)) { // Looks promising, lets load some information. diff --git a/backup/converter/imscc11/lib.php b/backup/converter/imscc11/lib.php index 0c1c6d6202c..56532fa8696 100644 --- a/backup/converter/imscc11/lib.php +++ b/backup/converter/imscc11/lib.php @@ -38,9 +38,10 @@ class imscc11_converter extends base_converter { * @return null|string backup::FORMAT_IMSCC11 if the Common Cartridge 1.1 is detected, null otherwise */ public static function detect_format($tempdir) { - global $CFG; - - $filepath = $CFG->dataroot . '/temp/backup/' . $tempdir; + $filepath = make_backup_temp_directory($tempdir, false); + if (!is_dir($filepath)) { + throw new convert_helper_exception('tmp_backup_directory_not_found', $filepath); + } $manifest = cc112moodle::get_manifest($filepath); if (file_exists($manifest)) { // Looks promising, lets load some information.