Fix calculation of `lastMessageID` when removing other conversation participants
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 10 Feb 2022 10:33:50 +0000 (11:33 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 10 Feb 2022 10:33:50 +0000 (11:33 +0100)
Without this `ORDER BY` usually the first visible message would've been set as
the `lastMessageID`, as that's the first row within the `conversation_message`
table.

files/lib/data/conversation/ConversationEditor.class.php

index 3b49e5731341e1094a27171d4721449cbb3b9df9..bdb40ea5cf098f0334f77ccc85be138a0e9038d8 100644 (file)
@@ -171,7 +171,8 @@ class ConversationEditor extends DatabaseObjectEditor {
                        FROM    wcf".WCF_N."_conversation_message
                        WHERE   conversationID = ?
                                AND time >= ?
-                               AND time <= ?";
+                               AND time <= ?
+                       ORDER BY time DESC";
                $statement = WCF::getDB()->prepareStatement($sql, 1);
                $statement->execute([
                        $this->conversationID,