MDL-63564 core_question: Avoid using UNION in get_users_in_context()

This commit is contained in:
Mihail Geshoski
2018-11-02 14:14:19 +08:00
parent 6cd2de3ceb
commit 076288307f
+8 -11
View File
@@ -360,21 +360,18 @@ class provider implements
// A user may have created or updated a question.
// Questions are linked against a question category, which has a contextid field.
$sql = "SELECT q.createdby AS userid
$sql = "SELECT q.createdby, q.modifiedby
FROM {question} q
JOIN {question_categories} cat ON cat.id = q.category
WHERE cat.contextid = :contextid
UNION
SELECT q.modifiedby AS userid
FROM {question} q
JOIN {question_categories} cat ON cat.id = q.category
WHERE cat.contextid = :contextidagain";
JOIN {question_categories} cat
ON cat.id = q.category
WHERE cat.contextid = :contextid";
$params = [
'contextid' => $context->id,
'contextidagain' => $context->id,
'contextid' => $context->id
];
$userlist->add_from_sql('userid', $sql, $params);
$userlist->add_from_sql('createdby', $sql, $params);
$userlist->add_from_sql('modifiedby', $sql, $params);
}
/**