From bc933bbbcac130427f88e1b704484d7acacfb8aa Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 20 Jan 2024 23:32:38 +0000 Subject: [PATCH] [core] set image->posted on posting --- core/imageboard/image.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/core/imageboard/image.php b/core/imageboard/image.php index 0f2415e2..50e441de 100644 --- a/core/imageboard/image.php +++ b/core/imageboard/image.php @@ -52,7 +52,7 @@ class Image implements \ArrayAccess public int $owner_id; public string $owner_ip; #[Field] - public ?string $posted = null; + public string $posted; #[Field] public ?string $source = null; #[Field] @@ -272,17 +272,12 @@ class Image implements \ArrayAccess { global $database, $user; - if (is_null($this->posted) || $this->posted == "") { - $this->posted = date('Y-m-d H:i:s', time()); - } - $props_to_save = [ "filename" => substr($this->filename, 0, 255), "filesize" => $this->filesize, "hash" => $this->hash, "mime" => strtolower($this->mime), "ext" => strtolower($this->ext), - "posted" => $this->posted, "source" => $this->source, "width" => $this->width, "height" => $this->height, @@ -296,6 +291,7 @@ class Image implements \ArrayAccess if (is_null($this->id)) { $props_to_save["owner_id"] = $user->id; $props_to_save["owner_ip"] = get_real_ip(); + $props_to_save["posted"] = date('Y-m-d H:i:s', time()); $props_sql = implode(", ", array_keys($props_to_save)); $vals_sql = implode(", ", array_map(fn ($prop) => ":$prop", array_keys($props_to_save)));