Commit 1fc64232 authored by jun's avatar jun
Browse files

Merge branch 'MDL-59909-master' of git://github.com/damyon/moodle

parents 7f91fb03 a66de3ca
......@@ -59,7 +59,10 @@ class api {
if (is_object($instanceorid)) {
$instance = $instanceorid;
} else {
$instance = $DB->get_record($modulename, array('id' => $instanceorid), '*', MUST_EXIST);
$instance = $DB->get_record($modulename, array('id' => $instanceorid), '*', IGNORE_MISSING);
}
if (!$instance) {
return false;
}
$course = get_course($instance->course);
......
......@@ -72,6 +72,13 @@ class core_completion_api_testcase extends advanced_testcase {
$this->assertEquals(\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED, $event->eventtype);
$this->assertEquals($time, $event->timestart);
$this->assertEquals($time, $event->timesort);
require_once($CFG->dirroot . '/course/lib.php');
// Delete the module.
course_delete_module($assign->cmid);
// Check we don't get a failure when called on a deleted module.
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', null, $time);
}
public function test_update_completion_date_event_update() {
......
......@@ -1404,7 +1404,9 @@ function course_module_update_calendar_events($modulename, $instance = null, $cm
if (!isset($cm)) {
$cm = get_coursemodule_from_instance($modulename, $instance->id, $instance->course);
}
course_module_calendar_event_update_process($instance, $cm);
if (!empty($cm)) {
course_module_calendar_event_update_process($instance, $cm);
}
return true;
}
return false;
......@@ -1433,8 +1435,9 @@ function course_module_bulk_update_calendar_events($modulename, $courseid = 0) {
}
foreach ($instances as $instance) {
$cm = get_coursemodule_from_instance($modulename, $instance->id, $instance->course);
course_module_calendar_event_update_process($instance, $cm);
if ($cm = get_coursemodule_from_instance($modulename, $instance->id, $instance->course)) {
course_module_calendar_event_update_process($instance, $cm);
}
}
return true;
}
......
......@@ -44,6 +44,10 @@ class refresh_mod_calendar_events_task extends adhoc_task {
* Run the task to refresh calendar events.
*/
public function execute() {
global $CFG;
require_once($CFG->dirroot . '/course/lib.php');
// Specific list of plugins that need to be refreshed. If not set, then all mod plugins will be refreshed.
$pluginstorefresh = null;
if (isset($this->get_custom_data()->plugins)) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment