Resetting it in load_all_capabilities() means it gets flushed everytime
role_assign() or role_unassign() is called on the current user, which should
be enough.
The cache is not reset when others assign/unassign roles, but Moodle has
always had this problem.
return;
}
+ unset($USER->mycourses); // Reset a cache used by get_my_courses
+
load_user_capability(); // Load basic capabilities assigned to this user
if ($USER->username == 'guest') {
*/
function get_my_courses($userid, $sort='visible DESC,sortorder ASC', $fields='*', $doanything=false,$limit=0) {
+ global $USER;
+
+ if (!empty($USER->id) && ($USER->id == $userid)) {
+ if (!empty($USER->mycourses)) {
+ return $USER->mycourses; // Just return the cached version
+ }
+ }
+
$mycourses = array();
// Fix fields to refer to the course table c