]> git.mjollnir.org Git - moodle.git/commitdiff
Added a checking flag to check_enrolment_plugins() to make sure that it
authormoodler <moodler>
Mon, 25 Sep 2006 01:34:21 +0000 (01:34 +0000)
committermoodler <moodler>
Mon, 25 Sep 2006 01:34:21 +0000 (01:34 +0000)
never repeats more than once in an invocation.  Otherwise it's sometimes
possible for role_assign() during the enrolment process to cause loops.

lib/accesslib.php

index 4d5a68dd83576399a11a60c880d4503a03d105ce..74866291e00b23c11ca085780c314bf13626be18 100755 (executable)
@@ -742,6 +742,14 @@ function load_user_capability($capability='', $context ='', $userid='') {
 function check_enrolment_plugins(&$user) {
     global $CFG;
 
+    static $inprogress;  // To prevent this function being called more than once in an invocation
+
+    if (!empty($inprogress)) {
+        return;
+    }
+
+    $inprogress = true;  // Set the flag
+
     require_once($CFG->dirroot .'/enrol/enrol.class.php');
 
     if (!($plugins = explode(',', $CFG->enrol_plugins_enabled))) {
@@ -766,6 +774,8 @@ function check_enrolment_plugins(&$user) {
         }
         unset($enrol);
     }
+
+    $inprogress = false;  // Unset the flag
 }