diff --git a/lib/accesslib.php b/lib/accesslib.php index a587c3e6c96..16022b6c0da 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -2649,9 +2649,10 @@ function get_users_by_capability($context, $capability, $fields='', $sort='', continue; } } - $caps = role_context_capabilities($possiblerole->id, $context, $capability); // resolved list - if ($caps[$capability] > 0) { // resolved capability > 0 - $validroleids[] = $possiblerole->id; + if ($caps = role_context_capabilities($possiblerole->id, $context, $capability)) { // resolved list + if (isset($caps[$capability]) && $caps[$capability] > 0) { // resolved capability > 0 + $validroleids[] = $possiblerole->id; + } } } if (empty($validroleids)) {