From: skodak Date: Sun, 17 Sep 2006 08:53:57 +0000 (+0000) Subject: infinite loop prevention when unassigning recursively X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=86e2c51da8ebf728483c213bf00cdae06a4e7512;p=moodle.git infinite loop prevention when unassigning recursively --- diff --git a/lib/accesslib.php b/lib/accesslib.php index 39d04aff8a..5fd248bc84 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -1459,7 +1459,12 @@ function role_unassign($roleid=0, $userid=0, $groupid=0, $contextid=0) { if ($ras = get_records_select('role_assignments', implode(' AND ', $select))) { $mods = get_list_of_plugins('mod'); foreach($ras as $ra) { + /// infinite loop protection when deleting recursively + if (!$ra = get_record('role_assignments', 'id', $ra->id)) { + continue; + } $success = delete_records('role_assignments', 'id', $ra->id) and $success; + /// If the user is the current user, then reload the capabilities too. if (!empty($USER->id) && $USER->id == $ra->userid) { load_user_capability();