From 5520b180c773362d9d9c1c72d01c8bfc8aef26b6 Mon Sep 17 00:00:00 2001 From: Michael Eshom Date: Sat, 8 Feb 2025 19:07:05 -0500 Subject: [PATCH] Ensure values have the right type when loading drafts --- Sources/Draft.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Sources/Draft.php b/Sources/Draft.php index 5c1aedcd23..c0a490b5e4 100644 --- a/Sources/Draft.php +++ b/Sources/Draft.php @@ -183,18 +183,21 @@ public function __construct(int $id_draft = 0, bool $check = true, array $recipi foreach ($draft_info as $key => $value) { switch ($key) { case 'id_draft': - $this->id = $value; + $this->id = (int) $value; break; case 'id_topic': case 'id_board': case 'id_member': + $this->{substr($key, 3)} = (int) $value; + break; + case 'is_sticky': - $this->{substr($key, 3)} = $value; + $this->sticky = !empty($value); break; case 'id_reply': - $this->reply_to = $value; + $this->reply_to = (int) $value; break; case 'to_list': @@ -202,6 +205,18 @@ public function __construct(int $id_draft = 0, bool $check = true, array $recipi $this->recipients['to'] = $recipientsList['to'] ?? []; $this->recipients['bcc'] = $recipientsList['bcc'] ?? []; break; + + // These have to be ints + case 'type': + case 'poster_time': + $this->type = (int) $value; + break; + + // Boolean values + case 'smileys_enabled': + case 'locked': + $this->$key = !empty($value); + break; default: $this->$key = $value;