Antwortmöglichkeit
This commit is contained in:
@@ -80,7 +80,7 @@ class Comment
|
||||
*/
|
||||
public function isReply(): bool
|
||||
{
|
||||
return $this->parentCommentId !== null;
|
||||
return $this->parentCommentId !== null && $this->parentCommentId !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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"]
|
||||
|
||||
Reference in New Issue
Block a user