]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
UseFileAsThumbnailException uses direct File object now
authorMikael Nordfeldth <mmn@hethane.se>
Wed, 4 May 2016 09:34:50 +0000 (11:34 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Wed, 4 May 2016 09:34:50 +0000 (11:34 +0200)
classes/File.php
lib/imagefile.php
lib/usefileasthumbnailexception.php

index 46d4d5498dc2980a442d67f100371a2edd900feb..4489b4ecc18d81b46c55725e594d9973ad3410cc 100644 (file)
@@ -498,7 +498,7 @@ class File extends Managed_DataObject
                     return File_thumbnail::byFile($this);
                 } catch (NoResultException $e) {
                     // and if it's not a remote file, it'll be safe to use the locally stored File
-                    throw new UseFileAsThumbnailException($this->id);
+                    throw new UseFileAsThumbnailException($this);
                 }
             }
         }
index 85fc59712690c7f6c1554d519294eb10729ed050..156e3c6fd2d18af4ec90c5efc5334ec9722d468a 100644 (file)
@@ -132,7 +132,7 @@ class ImageFile
             // First some mimetype specific exceptions
             switch ($file->mimetype) {
             case 'image/svg+xml':
-                throw new UseFileAsThumbnailException($file->id);
+                throw new UseFileAsThumbnailException($file);
             }
 
             // And we'll only consider it an image if it has such a media type
@@ -282,7 +282,11 @@ class ImageFile
         }
 
         if (!file_exists($outpath)) {
-            throw new UseFileAsThumbnailException($this->id);
+            if ($this->fileRecord instanceof File) {
+                throw new UseFileAsThumbnailException($this->fileRecord);
+            } else {
+                throw new UnsupportedMediaException('No local File object exists for ImageFile.');
+            }
         }
 
         return $outpath;
index cafbe692b284081fb64683228529d21ee7f8001e..5ad33cb0a9c1565b627cf9633ee981f38fed8671 100644 (file)
@@ -34,13 +34,9 @@ class UseFileAsThumbnailException extends UnsupportedMediaException
 {
     public $file = null;
 
-    public function __construct($file_id)
+    public function __construct(File $file)
     {
-        $this->file = File::getKV('id', $file_id);
-        if (!$this->file instanceof File) {
-            throw new ServerException('No File ID supplied to exception');
-        }
-
+        $this->file = $file;
         parent::__construct('Thumbnail not generated', $this->file->getPath());
     }
 }