From f6df1f1dd3735b66eaeab9a32e85615fe77e494d Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Wed, 4 Mar 2015 13:29:18 +0100 Subject: [PATCH] Documentation and more understandable code. --- lib/imagefile.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/imagefile.php b/lib/imagefile.php index 26663eed7b..97aa85c1ff 100644 --- a/lib/imagefile.php +++ b/lib/imagefile.php @@ -61,11 +61,16 @@ class ImageFile { $this->id = $id; if (!empty($this->id)) { - $this->fileRecord = File::getKV('id', $this->id); - if (!$this->fileRecord instanceof File) { - throw new ServerException('Expected File object did not exist.'); + $this->fileRecord = new File(); + $this->fileRecord->id = $this->id; + if (!$this->find(true)) { + // If we have set an ID, we need that ID to exist! + throw new NoResultException($this->fileRecord); } } + + // These do not have to be the same as fileRecord->filename for example, + // since we may have generated an image source file from something else! $this->filepath = $filepath; $this->filename = basename($filepath);