Antwortmöglichkeit

This commit is contained in:
2026-06-15 22:47:50 +02:00
parent efb179dec2
commit f23ec27247
2 changed files with 17 additions and 4 deletions
+1 -1
View File
@@ -80,7 +80,7 @@ class Comment
*/ */
public function isReply(): bool public function isReply(): bool
{ {
return $this->parentCommentId !== null; return $this->parentCommentId !== null && $this->parentCommentId !== 0;
} }
/** /**
+16 -3
View File
@@ -113,6 +113,10 @@ class DatabaseCommentManager implements CommentManagerDAO
try { try {
$db = $this->getConnection(); $db = $this->getConnection();
if ($parentCommentId === "" || $parentCommentId === 0 || $parentCommentId === "0") {
$parentCommentId = null;
}
$sql = " $sql = "
INSERT INTO comments ( INSERT INTO comments (
article_id, article_id,
@@ -173,12 +177,21 @@ class DatabaseCommentManager implements CommentManagerDAO
$comments = []; $comments = [];
while ($row = $command->fetch(PDO::FETCH_ASSOC)) { 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( $comments[] = new Comment(
intval($row["id"]), intval($row["id"]),
intval($row["article_id"]), intval($row["article_id"]),
isset($row["parent_comment_id"]) && $row["parent_comment_id"] !== null $parentCommentId,
? intval($row["parent_comment_id"])
: null,
$row["author"], $row["author"],
$row["content"], $row["content"],
$row["created"] $row["created"]