From bf2a34c1064b2103f8d5cd59695bbe5da6952759 Mon Sep 17 00:00:00 2001 From: Matthew Barbour Date: Thu, 8 Oct 2020 17:40:34 -0500 Subject: [PATCH] Adjusted mime type update statement to include NULLs. Changed get_mime() so that it can return a null in the event of the mime type not being properly set. --- core/imageboard/image.php | 2 +- ext/mime/main.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/imageboard/image.php b/core/imageboard/image.php index b65dc8ef..5d0e33c5 100644 --- a/core/imageboard/image.php +++ b/core/imageboard/image.php @@ -598,7 +598,7 @@ class Image /** * Get the image's mime type. */ - public function get_mime(): string + public function get_mime(): ?string { if ($this->mime===MimeType::WEBP&&$this->lossless) { return MimeType::WEBP_LOSSLESS; diff --git a/ext/mime/main.php b/ext/mime/main.php index bcbccdde..c98adde5 100644 --- a/ext/mime/main.php +++ b/ext/mime/main.php @@ -45,7 +45,7 @@ class MimeSystem extends Extension $normalized_extension = FileExtension::get_for_mime($mime); $database->execute( - "UPDATE images SET mime = :mime, ext = :new_ext WHERE ext = :ext AND (mime != :mime OR ext != :new_ext)", + "UPDATE images SET mime = :mime, ext = :new_ext WHERE ext = :ext AND (mime IS NULL OR mime != :mime OR ext != :new_ext)", ["mime" => $mime, "new_ext" => $normalized_extension, "ext" => $ext] ); }