Merge branch 'MDL-54035_master-fix' of git://github.com/dmonllao/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 26 Sep 2018 21:28:34 +0000 (23:28 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 26 Sep 2018 21:28:34 +0000 (23:28 +0200)
lib/accesslib.php

index 2ca9f4d..27ec530 100644 (file)
@@ -1019,7 +1019,9 @@ function reload_all_capabilities() {
     foreach ($sw as $path => $roleid) {
         if ($record = $DB->get_record('context', array('path'=>$path))) {
             $context = context::instance_by_id($record->id);
-            role_switch($roleid, $context);
+            if (has_capability('moodle/role:switchroles', $context)) {
+                role_switch($roleid, $context);
+            }
         }
     }
 }