From 7bfa3101df6a278df289e2fab5851e3a60ce419d Mon Sep 17 00:00:00 2001 From: skodak Date: Wed, 27 Sep 2006 18:11:36 +0000 Subject: [PATCH] add checks for stale contextid in role_assignments and overrides into load_user_capability() MDL-6708 --- lib/accesslib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/accesslib.php b/lib/accesslib.php index dc1a4c5fcd..d9187825d8 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -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).'"'); } -- 2.39.5