MDL-59909 calendar: Try hard not to fail the adhoc task.

Triggering a fatal error in an adhoc task is bad. It will be retried indefinitely.
Even though we are not sure how to get a module instance without a course module record,
it is possible and should not kill the Moodle site.
This commit is contained in:
Damyon Wiese
2017-10-25 15:44:00 +08:00
parent bcca46d630
commit 0203b05f13
4 changed files with 21 additions and 4 deletions
+4 -1
View File
@@ -59,7 +59,10 @@ class api {
if (is_object($instanceorid)) {
$instance = $instanceorid;
} else {
$instance = $DB->get_record($modulename, array('id' => $instanceorid), '*', MUST_EXIST);
$instance = $DB->get_record($modulename, array('id' => $instanceorid), '*', IGNORE_MISSING);
}
if (!$instance) {
return false;
}
$course = get_course($instance->course);