From 7189133861300c06a64d277fbd29913823a7b751 Mon Sep 17 00:00:00 2001 From: Caroline Schulte Date: Sat, 18 Jul 2026 18:09:11 +0200 Subject: [PATCH] Korrektur --- php/controller/showArticle-controller.php | 3 ++- php/model/Comment.php | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/php/controller/showArticle-controller.php b/php/controller/showArticle-controller.php index 676f812..dff5eae 100644 --- a/php/controller/showArticle-controller.php +++ b/php/controller/showArticle-controller.php @@ -49,8 +49,9 @@ if (isset($_GET["id"]) && !empty($_GET["id"])){ } } - } catch (Exception $e){ + } catch (Throwable $e) { $_SESSION["message"] = "internal_error"; + header("Location: index.php"); exit(); } }else{ diff --git a/php/model/Comment.php b/php/model/Comment.php index b92543b..a4b241a 100644 --- a/php/model/Comment.php +++ b/php/model/Comment.php @@ -13,7 +13,7 @@ class Comment private int $id; private int $articleId; private ?int $parentCommentId; - private string $author; + private ?string $author; private string $content; private string $created; @@ -23,7 +23,7 @@ class Comment * @param int $id Eindeutige ID des Kommentars * @param int $articleId ID des zugehörigen Beitrags * @param int|null $parentCommentId ID des Eltern-Kommentars oder null - * @param string $author Autor des Kommentars + * @param string|null $author Autor des Kommentars oder null bei gelöschten Kommentaren * @param string $content Inhalt des Kommentars * @param string $created Erstellungsdatum des Kommentars */ @@ -31,7 +31,7 @@ class Comment int $id, int $articleId, ?int $parentCommentId, - string $author, + ?string $author, string $content, string $created ) { @@ -86,9 +86,9 @@ class Comment /** * Gibt den Autor des Kommentars zurück. * - * @return string Autor + * @return string|null Autor oder null bei gelöschten Kommentaren */ - public function getAuthor(): string + public function getAuthor(): ?string { return $this->author; }