Fix exception when editing a user rank with a broken image
authorMarcel Werk <burntime@woltlab.com>
Fri, 3 Mar 2023 14:52:46 +0000 (15:52 +0100)
committerMarcel Werk <burntime@woltlab.com>
Fri, 3 Mar 2023 14:52:46 +0000 (15:52 +0100)
Closes #4860

wcfsetup/install/files/lib/data/user/rank/UserRank.class.php

index eab2a023b10e54804548b780c2d44e884fad8e4f..5eaa3bfd6ef4adc032bc957f4da886ea3fd1cd42 100644 (file)
@@ -76,13 +76,16 @@ class UserRank extends DatabaseObject implements ITitledObject
     public function getImageFile(): ?UploadFile
     {
         if ($this->rankImage) {
-            return new UploadFile(
-                WCF_DIR . self::RANK_IMAGE_DIR . $this->rankImage,
-                $this->rankImage,
-                true,
-                true,
-                true
-            );
+            $location = WCF_DIR . self::RANK_IMAGE_DIR . $this->rankImage;
+            if (\file_exists($location)) {
+                return new UploadFile(
+                    $location,
+                    $this->rankImage,
+                    true,
+                    true,
+                    true
+                );
+            }
         }
 
         return null;