MDL-30528 stop recreating role_assignments on every login attempt for each user
authorPetr Skoda <commits@skodak.org>
Sat, 3 Dec 2011 07:48:09 +0000 (08:48 +0100)
committerPetr Skoda <commits@skodak.org>
Tue, 6 Dec 2011 07:48:38 +0000 (08:48 +0100)
Credit goes to Luis Gustavo Mueller de Alcantara.

enrol/database/lib.php

index 306f8b3..33ddad4 100644 (file)
@@ -185,7 +185,7 @@ class enrol_database_plugin extends enrol_plugin {
 
             $existing = array();
             foreach ($current as $r) {
-                if (in_array($r->id, $roles)) {
+                if (in_array($r->roleid, $roles)) {
                     $existing[$r->roleid] = $r->roleid;
                 } else {
                     role_unassign($r->roleid, $user->id, $context->id, 'enrol_database', $instance->id);