From c8c746c440bf3e925cde377c78990f6e277ced2e Mon Sep 17 00:00:00 2001 From: PJ King Date: Wed, 17 Dec 2014 10:57:09 -0500 Subject: [PATCH] MDL-46671 availability: DEBUG when course_module does not exist. 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. --- availability/classes/info_module.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/availability/classes/info_module.php b/availability/classes/info_module.php index 201b7dc13af..83403455529 100644 --- a/availability/classes/info_module.php +++ b/availability/classes/info_module.php @@ -180,7 +180,12 @@ class info_module extends info { 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.