From 4e9e416671846d119fe9a0f9189d8e989076910e Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Tue, 7 May 2024 12:09:51 +0000
Subject: [PATCH] fixes #4127

Closes #4127

Merge request studip/studip!2970
---
 app/views/course/forum/area/add.php         | 4 ++--
 app/views/course/forum/index/_last_post.php | 2 +-
 lib/classes/ForumActivity.php               | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/app/views/course/forum/area/add.php b/app/views/course/forum/area/add.php
index 881c1220fd0..1449a5d698e 100644
--- a/app/views/course/forum/area/add.php
+++ b/app/views/course/forum/area/add.php
@@ -7,7 +7,7 @@
         <? else : ?>
             <? $num_postings = ForumVisit::getCount($entry['topic_id'], $visitdate) ?>
             <?= Icon::create('forum', $num_postings > 0 ? Icon::ROLE_ATTENTION : Icon::ROLE_INFO)->asImg([
-                'title' => ForumHelpers::getVisitText($num_postings, $entry['topic_id'], $constraint['depth']),
+                'title' => ForumHelpers::getVisitText($num_postings, $entry['topic_id']),
             ]) ?>
         <? endif ?>
     </td>
@@ -36,7 +36,7 @@
     </td>
 
     <td class="postings">
-        <?= number_format(max($entry['num_postings'] - 1, 0), 0, ',', '.') ?>
+        <?= number_format(max(($entry['num_postings'] ?? 0) - 1, 0), 0, ',', '.') ?>
     </td>
 
     <td class="answer hidden-tiny-down">
diff --git a/app/views/course/forum/index/_last_post.php b/app/views/course/forum/index/_last_post.php
index 3532d40e855..b5d854a82d4 100644
--- a/app/views/course/forum/index/_last_post.php
+++ b/app/views/course/forum/index/_last_post.php
@@ -1,4 +1,4 @@
-<? if (is_array($entry['last_posting']) && count($entry['last_posting'])) : ?>
+<? if (!empty($entry['last_posting']) && is_array($entry['last_posting'])) : ?>
     <?= _('von') ?>
     <? if (!empty($entry['last_posting']['anonymous'])): ?>
         <?= _('Anonym') ?>
diff --git a/lib/classes/ForumActivity.php b/lib/classes/ForumActivity.php
index bc00cf19313..a6a685d4646 100644
--- a/lib/classes/ForumActivity.php
+++ b/lib/classes/ForumActivity.php
@@ -124,7 +124,7 @@ class ForumActivity
             'mkdate'       => $post['mkdate'] ?? time()
         ];
 
-        if ($post['anonymous']) {
+        if (!empty($post['anonymous'])) {
             $data['actor_type'] = 'anonymous';
             $data['actor_id']   = '';
         }
-- 
GitLab