From c2d88da70873808949d88eaed42e80012452bd9d Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Fri, 25 Jan 2008 00:53:01 +0000 Subject: [PATCH] accesslib: Fix get_context_users_bycap() when no roles grant the cap When no roles mention the capability, get_context_users_bycap() breaks badly. This trivial patch does a sanity check before jumping into the SQL shark-pool... MDL-13160 --- lib/accesslib.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/accesslib.php b/lib/accesslib.php index b2a061336b..51d2f2d293 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -1145,6 +1145,10 @@ function get_context_users_bycap ($context, $capability='moodle/course:view', $f rs_close($rs); $roles = implode(',', $roles); + if (empty($roles)) { + return array(); + } + // // User permissions subselect SQL // -- 2.39.5