From: vyshane Date: Tue, 5 Sep 2006 03:07:56 +0000 (+0000) Subject: Fixed warning X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=4729012f4cf8c38800763c10eb9d5d5dd38c571b;p=moodle.git Fixed warning --- diff --git a/lib/accesslib.php b/lib/accesslib.php index 2b3909067c..e4f7757b36 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -1592,15 +1592,16 @@ function role_context_capabilities($roleid, $context, $cap='') { and rc.contextid = c.id $search ORDER BY c.aggregatelevel DESC, rc.capability DESC"; - $records = get_records_sql($SQL); $capabilities = array(); - // We are traversing via reverse order. - foreach ($records as $record) { - // If not set yet (i.e. inherit or not set at all), or currently we have a prohibit - if (!isset($capabilities[$record->capability]) || $record->permission<-500) { - $capabilities[$record->capability] = $record->permission; - } + if ($records = get_records_sql($SQL)) { + // We are traversing via reverse order. + foreach ($records as $record) { + // If not set yet (i.e. inherit or not set at all), or currently we have a prohibit + if (!isset($capabilities[$record->capability]) || $record->permission<-500) { + $capabilities[$record->capability] = $record->permission; + } + } } return $capabilities; }