]> git.mjollnir.org Git - moodle.git/commitdiff
get_my_courses(): tighten cache scheme
authormartinlanghoff <martinlanghoff>
Sun, 6 May 2007 05:22:03 +0000 (05:22 +0000)
committermartinlanghoff <martinlanghoff>
Sun, 6 May 2007 05:22:03 +0000 (05:22 +0000)
This tightens the rather lax caching mechanism that
cached regardless of parameters.

Thanks to Matt Clarkson for the heads-up...

lib/datalib.php

index 90bd0c7bc073c050509b0b4a4d2281a810a05ecf..d4f4a165efe74eb74689140793ab20928b21fab2 100644 (file)
@@ -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;
     }