From a597946e681a4f1dcbbf3ba0a5184d2f5e6e0c8f Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Tue, 21 Jun 2022 13:10:49 +0200 Subject: [PATCH] Add fallback for conversations without messages 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 | 6 ++++++ files/lib/page/ConversationPage.class.php | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/files/lib/data/conversation/ConversationAction.class.php b/files/lib/data/conversation/ConversationAction.class.php index 428c592..fb932ef 100644 --- a/files/lib/data/conversation/ConversationAction.class.php +++ b/files/lib/data/conversation/ConversationAction.class.php @@ -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(), diff --git a/files/lib/page/ConversationPage.class.php b/files/lib/page/ConversationPage.class.php index c30e3df..cab8890 100644 --- a/files/lib/page/ConversationPage.class.php +++ b/files/lib/page/ConversationPage.class.php @@ -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) { -- 2.20.1