MDL-49613 access: count_role_users gives unexpected results
The count_role_users function in lib/accesslib.php gives the wrong results if a user has the same role at multiple levels in a context path. For example a user is a coursecreator on a course and the category that the course is in, in this case they would be counted twice, rather than being recognised as the same user. This change will make the function only count unique users.
This commit is contained in:
+1
-1
@@ -4232,7 +4232,7 @@ function count_role_users($roleid, context $context, $parent = false) {
|
||||
|
||||
array_unshift($params, $context->id);
|
||||
|
||||
$sql = "SELECT COUNT(u.id)
|
||||
$sql = "SELECT COUNT(DISTINCT u.id)
|
||||
FROM {role_assignments} r
|
||||
JOIN {user} u ON u.id = r.userid
|
||||
WHERE (r.contextid = ? $parentcontexts)
|
||||
|
||||
Reference in New Issue
Block a user