MDL-24678 mod_chat: Fixed race condition on chat module
authorCarlos Alexandre S. da Fonseca <bozohhot@hotmail.com>
Tue, 21 Nov 2017 12:29:09 +0000 (10:29 -0200)
committerCarlos Alexandre S. da Fonseca <bozohhot@hotmail.com>
Fri, 24 Nov 2017 12:36:42 +0000 (10:36 -0200)
mod/chat/lib.php

index ef91dc1..f16e8a9 100644 (file)
@@ -566,7 +566,7 @@ function chat_get_latest_message($chatid, $groupid=0) {
 
     $sql = "SELECT *
         FROM {chat_messages_current} WHERE chatid = :chatid $groupselect
-        ORDER BY timestamp DESC";
+        ORDER BY timestamp DESC, id DESC";
 
     // Return the lastest one message.
     return $DB->get_record_sql($sql, $params, true);