Add fallback for conversations without messages empty-conversation-callback
authorMarcel Werk <burntime@woltlab.com>
Tue, 21 Jun 2022 11:10:49 +0000 (13:10 +0200)
committerMarcel Werk <burntime@woltlab.com>
Tue, 21 Jun 2022 11:10:49 +0000 (13:10 +0200)
Conversations that did not contain any messages for any reason could not be opened and therefore could not be left / deleted.

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

index 428c5928940cffe220f312ae8f65c16f52d3af4b..fb932ef29ff32e145cd3a3365ddfdff88c8ced53 100644 (file)
@@ -490,6 +490,12 @@ class ConversationAction extends AbstractDatabaseObjectAction implements
             ->add("conversation_message.messageID = ?", [$this->conversation->firstMessageID]);
         $messageList->readObjects();
 
+        if (!\count($messageList)) {
+            return [
+                'template' => '',
+            ];
+        }
+
         return [
             'template' => WCF::getTPL()->fetch('conversationMessagePreview', 'wcf', [
                 'message' => $messageList->getSingleObject(),
index c30e3dfc1afa527e8ca89fff023325558b08b2fe..cab8890084b866535873739b16588b663ca44319 100644 (file)
@@ -275,10 +275,10 @@ class ConversationPage extends MultipleLinkPage
 
         // get timeframe for modifications
         $this->objectList->rewind();
-        $startTime = ($this->conversation->joinedAt ?: $this->objectList->current()->time);
+        $count = \count($this->objectList);
+        $startTime = ($this->conversation->joinedAt ?: ($count ? $this->objectList->current()->time : $this->conversation->time));
         $endTime = ($this->conversation->leftAt ?: TIME_NOW);
 
-        $count = \count($this->objectList);
         if ($count > 1) {
             $this->objectList->seek($count - 1);
             if ($this->objectList->current()->time < $this->conversation->lastPostTime) {