From 26d8063c4506c9c51c7225ac261ba31bc573ee36 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Fri, 16 May 2025 11:57:07 +0200 Subject: [PATCH] Asset/Thumbnail: replace 'NULL' placeholder strings with actual null values --- models/Asset.php | 14 +++++++------- models/Thumbnail.php | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/models/Asset.php b/models/Asset.php index a4f8353..b008bf5 100644 --- a/models/Asset.php +++ b/models/Asset.php @@ -32,7 +32,7 @@ class Asset $this->$attribute = $value; } - if (isset($data['date_captured']) && $data['date_captured'] !== 'NULL' && !is_object($data['date_captured'])) + if (isset($data['date_captured']) && $data['date_captured'] !== null && !is_object($data['date_captured'])) $this->date_captured = new DateTime($data['date_captured']); } @@ -273,9 +273,9 @@ class Asset 'title' => $title, 'slug' => $slug, 'mimetype' => $mimetype, - 'image_width' => isset($image_width) ? $image_width : 'NULL', - 'image_height' => isset($image_height) ? $image_height : 'NULL', - 'date_captured' => isset($date_captured) ? $date_captured : 'NULL', + 'image_width' => isset($image_width) ? $image_width : null, + 'image_height' => isset($image_height) ? $image_height : null, + 'date_captured' => isset($date_captured) ? $date_captured : null, 'priority' => isset($priority) ? (int) $priority : 0, ]); @@ -504,9 +504,9 @@ class Asset [ 'id_asset' => $this->id_asset, 'mimetype' => $this->mimetype, - 'image_width' => isset($this->image_width) ? $this->image_width : 'NULL', - 'image_height' => isset($this->image_height) ? $this->image_height : 'NULL', - 'date_captured' => isset($this->date_captured) ? $this->date_captured : 'NULL', + 'image_width' => isset($this->image_width) ? $this->image_width : null, + 'image_height' => isset($this->image_height) ? $this->image_height : null, + 'date_captured' => isset($this->date_captured) ? $this->date_captured : null, 'priority' => $this->priority, ]); } diff --git a/models/Thumbnail.php b/models/Thumbnail.php index 8168ee2..2e9b3d6 100644 --- a/models/Thumbnail.php +++ b/models/Thumbnail.php @@ -335,7 +335,7 @@ class Thumbnail if ($success) { $thumb_selector = $this->width . 'x' . $this->height . $this->filename_suffix; - $this->thumbnails[$thumb_selector] = $filename !== 'NULL' ? $filename : null; + $this->thumbnails[$thumb_selector] = $filename ?? null; // For consistency, write new thumbnail filename to parent Image object. // TODO: there could still be an inconsistency if multiple objects exists for the same image asset. @@ -349,7 +349,7 @@ class Thumbnail private function markAsQueued() { - $this->updateDb('NULL'); + $this->updateDb(null); } private function markAsGenerated($filename)