Skip to content

Commit bccc093

Browse files
committed
Sort comments by timeposted AND id to avoid random behat failures
Without this change, the order comments are displayed in can be random if they're posted at the exact same second (as generally happens in behat testing). This causes a problem for the behat test when it just goes to delete the second comment on the page, assuming they're in order. This likely doesn't affect mysql, but definitely does affect pgsql.
1 parent a21284e commit bccc093

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

locallib.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ function oublog_get_posts($oublog, $context, $offset = 0, $cm, $groupid, $indivi
707707
FROM {oublog_comments} c
708708
LEFT JOIN {user} u ON c.userid = u.id
709709
WHERE c.postid IN (".implode(",", $postids).") AND c.deletedby IS NULL
710-
ORDER BY c.timeposted ASC ";
710+
ORDER BY c.timeposted ASC, c.id ASC ";
711711

712712
$rs = $DB->get_recordset_sql($sql);
713713
foreach ($rs as $comment) {
@@ -800,7 +800,7 @@ function oublog_get_post($postid, $canaudit=false) {
800800
$sql .= "AND c.deletedby IS NULL ";
801801
}
802802

803-
$sql .= "ORDER BY c.timeposted ASC ";
803+
$sql .= "ORDER BY c.timeposted ASC, c.id ASC ";
804804

805805
$rs = $DB->get_recordset_sql($sql, array($postid));
806806
foreach ($rs as $comment) {

0 commit comments

Comments
 (0)