Skip to content

Commit

Permalink
MDL-46671 availability: DEBUG when course_module does not exist.
Browse files Browse the repository at this point in the history
There was a fatal error when calendar event linked to non-extant activities.

Now, instead of throwing an exception when a course_module does not exist, is_user_visible() will print a debug statement.
  • Loading branch information
PJ King committed Jan 2, 2015
1 parent eb1dc9f commit c8c746c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion availability/classes/info_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,12 @@ public static function is_user_visible($cmorid, $userid = 0, $checkcourse = true
if (is_object($cmorid)) {
$cmorid = $cmorid->id;
}
$cm = $DB->get_record('course_modules', array('id' => $cmorid), '*', MUST_EXIST);
$cm = $DB->get_record('course_modules', array('id' => $cmorid));
if (!$cm) {
// In some error cases, the course module may not exist.
debugging('info_module::is_user_visible called with invalid cmid ' . $cmorid, DEBUG_DEVELOPER);
return false;
}
}

// If requested, check user can access the course.
Expand Down

0 comments on commit c8c746c

Please sign in to comment.