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.

This commit is contained in:
Matthew Barbour 2020-10-08 17:40:34 -05:00
parent 547c6d98da
commit bf2a34c106
2 changed files with 2 additions and 2 deletions

View file

@ -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;

View file

@ -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]
);
}