MDL-41157 calendar: improve calendar_get_course_cached
The function get_course() introduced in 2.5.1 will use $COURSE and $SITE to avoid an uncessary DB query, simplifying the logic of this function and improving perf.
This commit is contained in:
+1
-7
@@ -1391,14 +1391,8 @@ function calendar_get_module_cached(&$coursecache, $modulename, $instance) {
|
||||
* @return stdClass $coursecache[$courseid] return the specific course cache
|
||||
*/
|
||||
function calendar_get_course_cached(&$coursecache, $courseid) {
|
||||
global $COURSE, $DB;
|
||||
|
||||
if (!isset($coursecache[$courseid])) {
|
||||
if ($courseid == $COURSE->id) {
|
||||
$coursecache[$courseid] = $COURSE;
|
||||
} else {
|
||||
$coursecache[$courseid] = $DB->get_record('course', array('id'=>$courseid));
|
||||
}
|
||||
$coursecache[$courseid] = get_course($courseid);
|
||||
}
|
||||
return $coursecache[$courseid];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user