Fix the deletion of attachments through the file API
authorAlexander Ebert <ebert@woltlab.com>
Sun, 9 Jun 2024 19:28:59 +0000 (21:28 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 9 Jun 2024 19:28:59 +0000 (21:28 +0200)
wcfsetup/install/files/lib/system/file/processor/AttachmentFileProcessor.class.php

index 998a8daedd0a376695b8aec0a9ede8f92ee5fecd..a593282d5373ffd349f381c8281e72652d2be2cf 100644 (file)
@@ -6,6 +6,7 @@ use CuyZ\Valinor\Mapper\MappingError;
 use wcf\data\attachment\Attachment;
 use wcf\data\attachment\AttachmentAction;
 use wcf\data\attachment\AttachmentEditor;
+use wcf\data\attachment\AttachmentList;
 use wcf\data\file\File;
 use wcf\data\file\thumbnail\FileThumbnail;
 use wcf\http\Helper;
@@ -201,7 +202,11 @@ final class AttachmentFileProcessor extends AbstractFileProcessor
     #[\Override]
     public function delete(array $fileIDs, array $thumbnailIDs): void
     {
-        (new AttachmentAction($fileIDs, 'delete'))->executeAction();
+        $attachmentList = new AttachmentList();
+        $attachmentList->getConditionBuilder()->add("fileID IN (?)", [$fileIDs]);
+        $attachmentList->readObjects();
+
+        (new AttachmentAction($attachmentList->getObjects(), 'delete'))->executeAction();
     }
 
     #[\Override]