Fixed error when news comments category doesn't exist somehow.

This commit is contained in:
flash 2023-07-29 18:01:41 +00:00
parent e3c0ae662e
commit a89d8d26f4

View file

@ -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);
}