From c51fe594bf88b7ca12a88ce683c7ea2d5a9f01ea Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Mon, 3 Jun 2024 13:11:13 -0500 Subject: [PATCH] Fix artwork validation logic --- lib/Artwork.php | 4 ++-- www/artworks/post.php | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Artwork.php b/lib/Artwork.php index 2533bad6..dc159742 100644 --- a/lib/Artwork.php +++ b/lib/Artwork.php @@ -509,8 +509,8 @@ class Artwork{ } } - if($this->MimeType === null && !$error->Has('Exceptions\InvalidImageUploadException')){ - // Only notify of wrong mimetype if there is no other problem with the uploaded image + if($imagePath !== null && $this->MimeType === null && !$error->Has('Exceptions\InvalidImageUploadException')){ + // Only notify of wrong mimetype if there are no other problem with the uploaded image $error->Add(new Exceptions\InvalidMimeTypeException()); } diff --git a/www/artworks/post.php b/www/artworks/post.php index 98897d5f..13c30abb 100644 --- a/www/artworks/post.php +++ b/www/artworks/post.php @@ -68,6 +68,10 @@ try{ $artwork->Status = $newStatus; } + if(HttpInput::File('artwork-image') === null){ + $artwork->MimeType = $originalArtwork->MimeType; + } + $artwork->Save(HttpInput::File('artwork-image')); $_SESSION['artwork'] = $artwork;