mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-46931 roles: retrieve distinct users in sub-query.
Prevents duplicate key column warning when a user is enrolled in a course via multiple enrolment methods.
This commit is contained in:
parent
a713ed3ba6
commit
47e466c958
@ -69,8 +69,11 @@ class core_role_check_users_selector extends user_selector_base {
|
||||
|
||||
if ($coursecontext and $coursecontext != SITEID) {
|
||||
$sql1 = " FROM {user} u
|
||||
JOIN {user_enrolments} ue ON (ue.userid = u.id)
|
||||
JOIN {enrol} e ON (e.id = ue.enrolid AND e.courseid = :courseid1)
|
||||
JOIN (SELECT DISTINCT subu.id
|
||||
FROM {user} subu
|
||||
JOIN {user_enrolments} ue ON (ue.userid = subu.id)
|
||||
JOIN {enrol} e ON (e.id = ue.enrolid AND e.courseid = :courseid1)
|
||||
) subq ON subq.id = u.id
|
||||
WHERE $wherecondition";
|
||||
$params['courseid1'] = $coursecontext->instanceid;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user