Skip to content

Commit

Permalink
MDL-78674 calendar: No need to call get_course_and_cm_from_instance()
Browse files Browse the repository at this point in the history
The course ID and CM id can already be fetched from the event object.
  • Loading branch information
junpataleta committed Aug 10, 2023
1 parent 9ffdcf3 commit fd65fe1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions calendar/classes/local/api.php
Expand Up @@ -325,10 +325,12 @@ public static function update_event_start_day(
'core_calendar_event_timestart_updated',
[$legacyevent, $moduleinstance]
);
list($course, $cm) = get_course_and_cm_from_instance($event->get_course_module()->get('instance'),
$event->get_course_module()->get('modname'), $event->get_course()->get('id'));
\course_modinfo::purge_course_module_cache($course->id, $cm->id);
rebuild_course_cache($course->id, true, true);

// Rebuild the course cache to make sure the updated dates are reflected.
$courseid = $event->get_course()->get('id');
$cmid = $event->get_course_module()->get('id');
\course_modinfo::purge_course_module_cache($courseid, $cmid);
rebuild_course_cache($courseid, true, true);
}

return $mapper->from_legacy_event_to_event($legacyevent);
Expand Down

0 comments on commit fd65fe1

Please sign in to comment.