]> git.mjollnir.org Git - moodle.git/commitdiff
add checks for stale contextid in role_assignments and overrides into load_user_capab...
authorskodak <skodak>
Wed, 27 Sep 2006 18:11:36 +0000 (18:11 +0000)
committerskodak <skodak>
Wed, 27 Sep 2006 18:11:36 +0000 (18:11 +0000)
lib/accesslib.php

index dc1a4c5fcd3517a88b3efc6c6d53300419e6f418..d9187825d821dc5b62dd08d601dca432ea4a8999 100755 (executable)
@@ -694,7 +694,9 @@ function load_user_capability($capability='', $context ='', $userid='') {
     $usercap = array(); // for other user's capabilities
     foreach ($capabilities as $capability) {
 
-        $context = get_context_instance_by_id($capability->id);
+        if (!$context = get_context_instance_by_id($capability->id)) {
+            continue; // incorrect stale context
+        }
 
         if (!empty($otheruserid)) { // we are pulling out other user's capabilities, do not write to session
 
@@ -1222,7 +1224,7 @@ function get_context_instance($contextlevel=NULL, $instance=SITEID) {
 
 /// check allowed context levels
     if (!in_array($contextlevel, $allowed_contexts)) {
-        // fatal error, code must be fixed - probably typo or switched parameters 
+        // fatal error, code must be fixed - probably typo or switched parameters
         error('Error: get_context_instance() called with incorrect context level "'.s($contextlevel).'"');
     }