Fix the error handling of failed context validations
authorAlexander Ebert <ebert@woltlab.com>
Sat, 13 Apr 2024 16:45:51 +0000 (18:45 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 8 Jun 2024 10:19:38 +0000 (12:19 +0200)
wcfsetup/install/files/lib/system/file/processor/AttachmentFileProcessor.class.php

index d1fe6a9ceec2303cbfece3ebb7e323a5f1d812e8..65e62d4e0f1de2d3db7f4b0564b03e944b983a08 100644 (file)
@@ -9,7 +9,6 @@ use wcf\data\file\File;
 use wcf\data\file\thumbnail\FileThumbnail;
 use wcf\http\Helper;
 use wcf\system\attachment\AttachmentHandler;
-use wcf\system\exception\NotImplementedException;
 
 /**
  * @author Alexander Ebert
@@ -30,7 +29,7 @@ final class AttachmentFileProcessor implements IFileProcessor
     {
         $attachmentHandler = $this->getAttachmentHandlerFromContext($context);
         if ($attachmentHandler === null) {
-            return FileProcessorPreflightResult::InvalidContext;
+            return [];
         }
 
         return $attachmentHandler->getAllowedExtensions();
@@ -41,7 +40,10 @@ final class AttachmentFileProcessor implements IFileProcessor
     {
         $attachmentHandler = $this->getAttachmentHandlerFromContext($context);
         if ($attachmentHandler === null) {
-            return FileProcessorPreflightResult::InvalidContext;
+            // This can only happen whent he associated object has vanished
+            // while the file was being processed. There is nothing we can
+            // meaningfully do here.
+            return;
         }
 
         AttachmentEditor::fastCreate([
@@ -203,7 +205,7 @@ final class AttachmentFileProcessorContext
         /** @var non-empty-string */
         public readonly string $objectType,
 
-        /** @var positive-int */
+        /** @var non-negative-int */
         public readonly int $objectID,
 
         /** @var non-negative-int */