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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user