From e3766711361778001c28cc7e1d95af37451d91a5 Mon Sep 17 00:00:00 2001 From: flashwave Date: Sun, 10 Sep 2023 19:13:36 +0000 Subject: [PATCH] Attempt at fixing forum issues. --- public-legacy/forum/forum.php | 6 ++++-- public-legacy/forum/posting.php | 2 +- templates/forum/macros.twig | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/public-legacy/forum/forum.php b/public-legacy/forum/forum.php index 9cf92eb..2a4ce15 100644 --- a/public-legacy/forum/forum.php +++ b/public-legacy/forum/forum.php @@ -139,7 +139,6 @@ if($categoryInfo->mayHaveTopics()) { $topic->info = $topicInfo; $topic->unread = $forumTopics->checkTopicUnread($topicInfo, $currentUser); $topic->participated = $forumTopics->checkTopicParticipated($topicInfo, $currentUser); - $topic->lastPost = new stdClass; if($topicInfo->hasUserId()) { $topic->user = $usersCtx->getUserInfo($topicInfo->getUserId()); @@ -147,6 +146,7 @@ if($categoryInfo->mayHaveTopics()) { } try { + $topic->lastPost = new stdClass; $topic->lastPost->info = $lastPostInfo = $forumPosts->getPost( topicInfo: $topicInfo, getLast: true, @@ -157,7 +157,9 @@ if($categoryInfo->mayHaveTopics()) { $topic->lastPost->user = $usersCtx->getUserInfo($lastPostInfo->getUserId()); $topic->lastPost->colour = $usersCtx->getUserColour($topic->lastPost->user); } - } catch(RuntimeException $ex) {} + } catch(RuntimeException $ex) { + $topic->lastPost = null; + } } } diff --git a/public-legacy/forum/posting.php b/public-legacy/forum/posting.php index 94b6913..7f8d315 100644 --- a/public-legacy/forum/posting.php +++ b/public-legacy/forum/posting.php @@ -214,7 +214,7 @@ if(!empty($_POST)) { ); $topicId = $topicInfo->getId(); - $forumTopics->incrementCategoryTopics($categoryInfo); + $forumCategories->incrementCategoryTopics($categoryInfo); } else $forumTopics->bumpTopic($topicInfo); diff --git a/templates/forum/macros.twig b/templates/forum/macros.twig index 78fb450..3359835 100644 --- a/templates/forum/macros.twig +++ b/templates/forum/macros.twig @@ -351,7 +351,7 @@ {% set topic_author_colour = '--user-colour: ' ~ topic.colour %} {% endif %} - {% set has_reply = topic.lastPost is defined %} + {% set has_reply = topic.lastPost is defined and topic.lastPost is not null %} {% if has_reply %} {% set reply_id = topic.lastPost.info.id %} {% set reply_created = topic.lastPost.info.createdTime %}