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.
This commit is contained in:
stronk7
2009-03-20 12:01:38 +00:00
parent 5e7932a38f
commit cc18654ce9
+2 -2
View File
@@ -1252,9 +1252,9 @@ function get_user_access_sitewide($userid) {
JOIN {$CFG->prefix}role_capabilities rco
ON (rco.roleid=ra.roleid AND rco.contextid=sctx.id)
WHERE ra.userid = $userid
AND sctx.contextlevel <= ".CONTEXT_COURSE."
AND ctx.contextlevel <= ".CONTEXT_COURSECAT."
AND sctx.contextlevel <= ".CONTEXT_COURSE."
ORDER BY sctx.depth, sctx.path, ra.roleid";
$rs = get_recordset_sql($sql);
if ($rs) {
while ($rd = rs_fetch_next_record($rs)) {