Skip to content

Commit

Permalink
MDL-57730 core_calendar: handle '0' as a courseid
Browse files Browse the repository at this point in the history
User overrides set the course id as 0 in the events table
(Moodle can be stupid). We need to deal with this.

Part of MDL-55611 epic.
  • Loading branch information
mdjnelson authored and Damyon Wiese committed Apr 3, 2017
1 parent 5e6e3ba commit bb19f80
Showing 1 changed file with 7 additions and 4 deletions.
Expand Up @@ -87,12 +87,15 @@ public function create_instance(\stdClass $dbrow) {
$module = null;
$subscription = null;

if ($dbrow->courseid) {
$course = new std_proxy($dbrow->courseid, function($id) use ($coursecache) {
return \core_calendar\api::get_course_cached($coursecache, $id);
});
if ($dbrow->courseid == 0) {
$cm = get_coursemodule_from_instance($dbrow->modulename, $dbrow->instance);
$dbrow->courseid = get_course($cm->course)->id;
}

$course = new std_proxy($dbrow->courseid, function($id) use ($coursecache) {
return \core_calendar\api::get_course_cached($coursecache, $id);
});

if ($dbrow->groupid) {
$group = new std_proxy($dbrow->groupid, function($id) {
return \core_calendar\api::get_group_cached($id);
Expand Down

0 comments on commit bb19f80

Please sign in to comment.