Prevent method calls on `null` in ConversationMessageAttachmentObjectType::canDownload()
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 23 Sep 2021 10:08:02 +0000 (12:08 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 23 Sep 2021 10:08:02 +0000 (12:08 +0200)
This may happen for attachments where the corresponding conversation /
conversation message no longer exists.

files/lib/system/attachment/ConversationMessageAttachmentObjectType.class.php

index ce7e96d6d548f3c7b855b57e4ac850be12cd9112..621c1ed7d5205434a866839f4cd40bcbf3766ea9 100644 (file)
@@ -55,7 +55,7 @@ class ConversationMessageAttachmentObjectType extends AbstractAttachmentObjectTy
         if ($objectID) {
             $message = new ConversationMessage($objectID);
             $conversation = Conversation::getUserConversation($message->conversationID, WCF::getUser()->userID);
-            if ($conversation->canRead()) {
+            if ($conversation !== null && $conversation->canRead()) {
                 return true;
             }
         }