Skip to content

Commit

Permalink
accesslib: Fix get_context_users_bycap() when no roles grant the cap
Browse files Browse the repository at this point in the history
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
  • Loading branch information
martinlanghoff committed Jan 25, 2008
1 parent c648a22 commit c2d88da
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/accesslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down

0 comments on commit c2d88da

Please sign in to comment.