From: Frederic Massart Date: Wed, 28 Jan 2015 07:02:26 +0000 (+0800) Subject: Enrol script does not die when manual enrol method is not found X-Git-Tag: v1.5.1~4 X-Git-Url: http://git.cameron1729.xyz/?p=mdk.git;a=commitdiff_plain;h=63c91d03c47a13f9aac0b55421eabffc99f0f7fb Enrol script does not die when manual enrol method is not found --- diff --git a/mdk/scripts/enrol.php b/mdk/scripts/enrol.php index 2803fe3..ea02948 100644 --- a/mdk/scripts/enrol.php +++ b/mdk/scripts/enrol.php @@ -20,6 +20,9 @@ function mdk_get_enrol_instance($courseid) { static $coursecache = array(); if (!isset($coursecache[$courseid])) { $coursecache[$courseid] = $DB->get_record('enrol', array('courseid' => $courseid, 'enrol' => 'manual')); + if (!$coursecache[$courseid]) { + mtrace("Could not find manual enrolment method for course {$courseid}."); + } } return $coursecache[$courseid]; } @@ -66,6 +69,9 @@ foreach ($users as $user) { } foreach ($courses as $course) { $instance = mdk_get_enrol_instance($course->id); + if (!$instance) { + continue; + } // Enrol the day before the course startdate, because if we create a course today its default // startdate is tomorrow, and we would never realise why the enrolments do not work. $plugin->enrol_user($instance, $user->id, $role->id, $course->startdate - 86400, 0);