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:
Dan Poltawski
2013-08-14 11:06:17 +08:00
parent d0cd4de2dd
commit ad2fc9d060
+1 -7
View File
@@ -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];
}