Fix the loading of the files of attachments
authorAlexander Ebert <ebert@woltlab.com>
Mon, 15 Apr 2024 16:19:53 +0000 (18:19 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 8 Jun 2024 10:19:38 +0000 (12:19 +0200)
The list of files (plus their thumbnails) is already fetched in the base implementation `AttachmentList`.

wcfsetup/install/files/lib/data/attachment/GroupedAttachmentList.class.php

index 81af576e26d2b1333e6a9cd17508e535da11d9d4..6f38520a17daaa3b6e58e8661b0ac2008ba74a79 100644 (file)
@@ -2,7 +2,6 @@
 
 namespace wcf\data\attachment;
 
-use wcf\data\file\FileList;
 use wcf\data\object\type\ObjectTypeCache;
 
 /**
@@ -77,8 +76,6 @@ class GroupedAttachmentList extends AttachmentList
     {
         parent::readObjects();
 
-        $fileIDs = [];
-
         // group by object id
         foreach ($this->objects as $attachmentID => $attachment) {
             if (!isset($this->groupedObjects[$attachment->objectID])) {
@@ -86,24 +83,6 @@ class GroupedAttachmentList extends AttachmentList
             }
 
             $this->groupedObjects[$attachment->objectID][$attachmentID] = $attachment;
-
-            if ($attachment->fileID) {
-                $fileIDs[] = $attachment->fileID;
-            }
-        }
-
-        if ($fileIDs !== []) {
-            $fileList = new FileList();
-            $fileList->setObjectIDs($fileIDs);
-            $fileList->readObjects();
-            $files = $fileList->getObjects();
-
-            foreach ($this->objects as $attachment) {
-                if ($attachment->fileID) {
-                    $file = $files[$attachment->fileID];
-                    $attachment->setFile($file);
-                }
-            }
         }
     }