]> git.mjollnir.org Git - moodle.git/commitdiff
accesslib: Fix get_context_users_bycap() when no roles grant the cap
authormartinlanghoff <martinlanghoff>
Fri, 25 Jan 2008 00:53:01 +0000 (00:53 +0000)
committermartinlanghoff <martinlanghoff>
Fri, 25 Jan 2008 00:53:01 +0000 (00:53 +0000)
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

index b2a061336ba72f09de0675be487d3af439c1a0b3..51d2f2d2937b41a0a2b4e86e21266d592d15ff02 100755 (executable)
@@ -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
     //