-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
4.1.17, 4.4.4, 4.4.6, 4.5
-
MOODLE_401_STABLE, MOODLE_404_STABLE, MOODLE_405_STABLE
-
MDL-84456-main
-
-
When copying a course, the task may fail with the following error with no stacktrace:
> Course copy: Can not load backup controller for copy, marking job as failed
This is because we catch the error and only print the above message:
mtrace('Course copy: Processing asynchronous course copy for course id: ' . $backuprecord->itemid); |
try { |
$bc = \backup_controller::load_controller($backupid); // Get the backup controller by backup id. |
} catch (\backup_dbops_exception $e) { |
mtrace('Course copy: Can not load backup controller for copy, marking job as failed'); |
delete_course($restorerecord->itemid, false); // Clean up partially created destination course. |
return; // Return early as we can't continue. |
}
|
|
It would make debugging task failures easier if the stacktrace was displayed.
—
Looking at the 'asynchronous_backup_task', `load_controller` is called without a try/catch block. For this task, we catch the error because we need to cleanup the destination course, but we don't rethrow the error. This means we cannot tell which of the three errors are thrown:
public static function load_controller($backupid) { |
global $DB;
|
if (! $controllerrec = $DB->get_record('backup_controllers', array('backupid' => $backupid))) { |
throw new backup_dbops_exception('backup_controller_dbops_nonexisting'); |
}
|
$controller = unserialize(base64_decode($controllerrec->controller));
|
if (!is_object($controller)) { |
// The controller field of the table did not contain a serialized object. |
// It is made empty after it has been used successfully, it is likely that |
// the user has pressed the browser back button at some point. |
throw new backup_dbops_exception('backup_controller_dbops_loading_invalid_controller'); |
}
|
// Check checksum is ok. Sounds silly but it isn't ;-) |
if (!$controller->is_checksum_correct($controllerrec->checksum)) { |
throw new backup_dbops_exception('backup_controller_dbops_loading_checksum_mismatch'); |
}
|
return $controller; |
}
|