Incorrect sort order when the user was removed
authorAlexander Ebert <ebert@woltlab.com>
Sat, 11 Jun 2022 11:40:49 +0000 (13:40 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 11 Jun 2022 11:40:49 +0000 (13:40 +0200)
See https://www.woltlab.com/community/thread/295198-sortierung-von-konversationen-fehlerhaft-wenn-teilnehmer-entfernt-wird/

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

index 428c5928940cffe220f312ae8f65c16f52d3af4b..31fa8cc9a1b6bcea9a0c12aef7721e8fbcf1d00a 100644 (file)
@@ -901,6 +901,12 @@ class ConversationAction extends AbstractDatabaseObjectAction implements
             }
         }
 
+        // Being removed from a conversation might show a different time
+        // for the last message, requiring the items to be sorted again.
+        \usort($conversations, static function (ViewableConversation $a, ViewableConversation $b) {
+            return $b->lastPostTime <=> $a->lastPostTime;
+        });
+
         $totalCount = ConversationHandler::getInstance()->getUnreadConversationCount();
         if ($count < 10 && $count < $totalCount) {
             UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'unreadConversationCount');