From 6b12e2fbd987a4057c2b9b0c282be08a9fe0ef74 Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Thu, 4 Apr 2024 08:03:07 +0000
Subject: [PATCH] fixes #3898

Closes #3898

Merge request studip/studip!2795
---
 app/controllers/course/wiki.php | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/app/controllers/course/wiki.php b/app/controllers/course/wiki.php
index 7a3a09ed31f..06317b67a95 100644
--- a/app/controllers/course/wiki.php
+++ b/app/controllers/course/wiki.php
@@ -282,11 +282,18 @@ class Course_WikiController extends AuthenticatedController
 
     public function allpages_action()
     {
-        Navigation::activateItem('/course/wiki/allpages');
         $this->pages = WikiPage::findBySQL(
             "`range_id` = ? ORDER BY `name` ASC",
             [$this->range->id]
         );
+
+        if (count($this->pages) === 0) {
+            $this->redirect($this->pageURL());
+            return;
+        }
+
+        Navigation::activateItem('/course/wiki/allpages');
+
         if ($GLOBALS['perm']->have_studip_perm('tutor', $this->range->id)) {
             $actions = new ActionsWidget();
             $actions->addLink(
-- 
GitLab