Error Backup course: Undefined function make_backup_temp_directory()

Error Backup course: Undefined function make_backup_temp_directory()

by Pakpoom Boonjeed -
Number of replies: 1

after use moodle for 2 year my raid card on server fail

after fix raid card,  i can't backup any course on moodle this message keep popup


Exception - Call to undefined function make_backup_temp_directory()

More information about this error

×Debug info: 
Error code: generalexceptionmessage
×Stack trace:
  • line 63 of /backup/util/factories/backup_factory.class.php: Error thrown
  • line 109 of /backup/controller/backup_controller.class.php: call to backup_factory::get_logger_chain()
  • line 99 of /backup/backup.php: call to backup_controller->__construct()

System information

moodle Ver 3.5+(Build: 20180524)

DB mariadb 10.1.38

php 7.0.33


thank you for help

Average of ratings: -
In reply to Pakpoom Boonjeed

Re: Error Backup course: Undefined function make_backup_temp_directory()

by Dominique Palumbo -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi,

as I see it in the Moodle github (see the link) it seems that the function make_backup_temp_directory() was introduce with this MDL in these files (for Moodle 3.4, 3.5). The comment is interresting -> // Need to ensure that $CFG->backuptempdir already exists.

The problem seems that the function doesn't exist in your Moodle 3.5+ !
Verify that you're moodle 3.5+ doesn't have patches. For some reason maybe 3.4 and 3.5 was patched but not the 3.5+.

backup/util/factories/backup_factory.class.php

@@ -60,9 +60,9 @@ public static function get_logger_chain($interactive, $execution, $backupid) {
// Create file_logger, observing $CFG->backup_file_logger_level
// defaulting to $dfltloglevel
check_dir_exists($CFG->tempdir . '/backup', true, true); // need to ensure that temp/backup already exists
$backuptempdir = make_backup_temp_directory(''); // Need to ensure that $CFG->backuptempdir already exists.
$fllevel = isset($CFG->backup_file_logger_level) ? $CFG->backup_file_logger_level : $dfltloglevel;
$enabledloggers[] = new file_logger($fllevel, true, true, $CFG->tempdir . '/backup/' . $backupid . '.log');
$enabledloggers[] = new file_logger($fllevel, true, true, $backuptempdir . '/' . $backupid . '.log');
// Create database_logger, observing $CFG->backup_database_logger_level and defaulting to LOG_WARNING
// and pointing to the backup_logs table

the function should be there from the same MDL-60923 .

lib/setuplib.php

/**
* Create a directory under $CFG->backuptempdir and make sure it is writable.
*
* Do not use for storing generic temp files - see make_temp_directory() instead for this purpose.
*
* Backup temporary files must be on a shared storage.
*
* @param string $directory the relative path of the directory to be created under $CFG->backuptempdir
* @param bool $exceptiononerror throw exception if error encountered
* @return string|false Returns full path to directory if successful, false if not; may throw exception
*/
function make_backup_temp_directory($directory, $exceptiononerror = true) {
global $CFG;
if ($CFG->backuptempdir !== "$CFG->tempdir/backup") {
check_dir_exists($CFG->backuptempdir, true, true);
protect_directory($CFG->backuptempdir);
} else {
protect_directory($CFG->tempdir);
}
return make_writable_directory("$CFG->backuptempdir/$directory", $exceptiononerror);
}

(You can also verify that you've this parameter (backuptempdir) set maybe it was loose for some reasons like cache clear, parameters reloaded, etc. (but seems not your problem))

hope it's help.


(I put the code to let you see in your own moodle if you've these code)