From 63c91d03c47a13f9aac0b55421eabffc99f0f7fb Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Wed, 28 Jan 2015 15:02:26 +0800 Subject: [PATCH] Enrol script does not die when manual enrol method is not found --- mdk/scripts/enrol.php | 6 ++++++ 1 file changed, 6 insertions(+) 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); -- 2.11.0