From a89d8d26f4d329652bb3a3f9befa48ee4ad56e13 Mon Sep 17 00:00:00 2001 From: flashwave Date: Sat, 29 Jul 2023 18:01:41 +0000 Subject: [PATCH] Fixed error when news comments category doesn't exist somehow. --- src/Http/Handlers/NewsHandler.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Http/Handlers/NewsHandler.php b/src/Http/Handlers/NewsHandler.php index c0d19a0..5f492ea 100644 --- a/src/Http/Handlers/NewsHandler.php +++ b/src/Http/Handlers/NewsHandler.php @@ -126,9 +126,12 @@ final class NewsHandler extends Handler { $comments = $this->context->getComments(); - if($postInfo->hasCommentsCategoryId()) { - $commentsCategory = $comments->getCategoryById($postInfo->getCommentsCategoryId()); - } else { + if($postInfo->hasCommentsCategoryId()) + try { + $commentsCategory = $comments->getCategoryById($postInfo->getCommentsCategoryId()); + } catch(RuntimeException $ex) {} + + if(!isset($commentsCategory)) { $commentsCategory = $comments->ensureCategory($postInfo->getCommentsCategoryName()); $news->updatePostCommentCategory($postInfo, $commentsCategory); }