mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-78156 groups: Make groups_get_user_groups() order deterministic
Right now the order of the groups returned by groups_get_user_groups() is not fixed and, every DB, can return them in any order. While 99% of times the order will be the creation one, depending of the RDBMS decisions, they can be returned in any order. This is specially noticeable with Oracle, but can affect to any DB. And that makes some tests (expecting a given order) to fail. This commit fixes the problem by making the order of the groups deterministic, because that's the way we use to fix these problems. Alternative is to relax the tests so only values are asserted by using assertEqualsCanonicalizing().
This commit is contained in:
parent
5d320dd7d1
commit
e12c760a12
@ -489,6 +489,8 @@ function groups_get_user_groups($courseid, $userid=0) {
|
||||
$params = array_merge($params, $visibilityparams);
|
||||
}
|
||||
|
||||
$sql .= ' ORDER BY g.id'; // To make results deterministic.
|
||||
|
||||
$rs = $DB->get_recordset_sql($sql, $params);
|
||||
|
||||
$usergroups = array();
|
||||
|
Loading…
x
Reference in New Issue
Block a user