Asset/Thumbnail: replace 'NULL' placeholder strings with actual null values

This commit is contained in:
Aaron van Geffen 2025-05-16 11:57:07 +02:00
parent 3dfda45681
commit 26d8063c45
2 changed files with 9 additions and 9 deletions

View File

@ -32,7 +32,7 @@ class Asset
$this->$attribute = $value; $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']); $this->date_captured = new DateTime($data['date_captured']);
} }
@ -273,9 +273,9 @@ class Asset
'title' => $title, 'title' => $title,
'slug' => $slug, 'slug' => $slug,
'mimetype' => $mimetype, 'mimetype' => $mimetype,
'image_width' => isset($image_width) ? $image_width : 'NULL', 'image_width' => isset($image_width) ? $image_width : null,
'image_height' => isset($image_height) ? $image_height : 'NULL', 'image_height' => isset($image_height) ? $image_height : null,
'date_captured' => isset($date_captured) ? $date_captured : 'NULL', 'date_captured' => isset($date_captured) ? $date_captured : null,
'priority' => isset($priority) ? (int) $priority : 0, 'priority' => isset($priority) ? (int) $priority : 0,
]); ]);
@ -504,9 +504,9 @@ class Asset
[ [
'id_asset' => $this->id_asset, 'id_asset' => $this->id_asset,
'mimetype' => $this->mimetype, 'mimetype' => $this->mimetype,
'image_width' => isset($this->image_width) ? $this->image_width : 'NULL', 'image_width' => isset($this->image_width) ? $this->image_width : null,
'image_height' => isset($this->image_height) ? $this->image_height : 'NULL', 'image_height' => isset($this->image_height) ? $this->image_height : null,
'date_captured' => isset($this->date_captured) ? $this->date_captured : 'NULL', 'date_captured' => isset($this->date_captured) ? $this->date_captured : null,
'priority' => $this->priority, 'priority' => $this->priority,
]); ]);
} }

View File

@ -335,7 +335,7 @@ class Thumbnail
if ($success) if ($success)
{ {
$thumb_selector = $this->width . 'x' . $this->height . $this->filename_suffix; $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. // 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. // 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() private function markAsQueued()
{ {
$this->updateDb('NULL'); $this->updateDb(null);
} }
private function markAsGenerated($filename) private function markAsGenerated($filename)