MDL-15748 get_user_access_sitewide() - reduce looking for perms in any context below category level.

Dramatic speed-up in sites with zillions of contexts and overrides. Credit goes to Samuli Karevaara.
Merged from 19_STABLE
This commit is contained in:
stronk7
2009-03-20 12:10:47 +00:00
parent 6bfa3f3ecf
commit 004865e20d
+2 -1
View File
@@ -1314,7 +1314,8 @@ function get_user_access_sitewide($userid) {
JOIN {role_capabilities} rco
ON (rco.roleid=ra.roleid AND rco.contextid=sctx.id)
WHERE ra.userid = ?
AND sctx.contextlevel <= ".CONTEXT_COURSE."
AND ctx.contextlevel <= ".CONTEXT_COURSECAT."
AND sctx.contextlevel <= ".CONTEXT_COURSE."
ORDER BY sctx.depth, sctx.path, ra.roleid";
$params = array($userid);
$rs = $DB->get_recordset_sql($sql, $params);