From f23ec27247b27f4e5e2ffbcd1bc51c0b36d9b75d Mon Sep 17 00:00:00 2001 From: Caroline Schulte Date: Mon, 15 Jun 2026 22:47:50 +0200 Subject: [PATCH] =?UTF-8?q?Antwortm=C3=B6glichkeit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- php/model/Comment.php | 2 +- php/model/DatabaseCommentManager.php | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/php/model/Comment.php b/php/model/Comment.php index 47595f8..b92543b 100644 --- a/php/model/Comment.php +++ b/php/model/Comment.php @@ -80,7 +80,7 @@ class Comment */ public function isReply(): bool { - return $this->parentCommentId !== null; + return $this->parentCommentId !== null && $this->parentCommentId !== 0; } /** diff --git a/php/model/DatabaseCommentManager.php b/php/model/DatabaseCommentManager.php index 8cd66cf..3bba78c 100644 --- a/php/model/DatabaseCommentManager.php +++ b/php/model/DatabaseCommentManager.php @@ -113,6 +113,10 @@ class DatabaseCommentManager implements CommentManagerDAO try { $db = $this->getConnection(); + if ($parentCommentId === "" || $parentCommentId === 0 || $parentCommentId === "0") { + $parentCommentId = null; + } + $sql = " INSERT INTO comments ( article_id, @@ -173,12 +177,21 @@ class DatabaseCommentManager implements CommentManagerDAO $comments = []; while ($row = $command->fetch(PDO::FETCH_ASSOC)) { + $parentCommentId = null; + + if ( + isset($row["parent_comment_id"]) + && $row["parent_comment_id"] !== null + && $row["parent_comment_id"] !== "" + && intval($row["parent_comment_id"]) !== 0 + ) { + $parentCommentId = intval($row["parent_comment_id"]); + } + $comments[] = new Comment( intval($row["id"]), intval($row["article_id"]), - isset($row["parent_comment_id"]) && $row["parent_comment_id"] !== null - ? intval($row["parent_comment_id"]) - : null, + $parentCommentId, $row["author"], $row["content"], $row["created"]