From: martinlanghoff Date: Sun, 6 May 2007 05:22:03 +0000 (+0000) Subject: get_my_courses(): tighten cache scheme X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c6325ef155aef155cab6fe3888f6ac2d741a6db7;p=moodle.git get_my_courses(): tighten cache scheme This tightens the rather lax caching mechanism that cached regardless of parameters. Thanks to Matt Clarkson for the heads-up... --- diff --git a/lib/datalib.php b/lib/datalib.php index 90bd0c7bc0..d4f4a165ef 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -684,9 +684,11 @@ function get_my_courses($userid, $sort='visible DESC,sortorder ASC', $fields='*' global $USER; - if (!empty($USER->id) && ($USER->id == $userid)) { + // If using default params, we may have it cached... + if (!empty($USER->id) && ($USER->id == $userid) + && $sort==='visible DESC,sortorder ASC' && $fields==='*') { if (!empty($USER->mycourses[$doanything])) { - return $USER->mycourses[$doanything]; // Just return the cached version + return $USER->mycourses[$doanything]; } } @@ -822,7 +824,7 @@ ORDER BY $sort"); // MDL-9671, my courses should only get cached when '*' is chosen as the field, otherwise courses // can not be displayed properly as cached courses might contain missing course name etc - if (!empty($USER->id) && ($USER->id == $userid) && $fields=='*') { + if (!empty($USER->id) && ($USER->id == $userid) && $fields==='*') { $USER->mycourses[$doanything] = $mycourses; }