From 8d3ddd26c7b66591a4ca5990756cd6ea298b066e Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Tue, 17 Oct 2023 09:13:20 +0000
Subject: [PATCH] fixes #3284

Closes #3284

Merge request studip/studip!2218
---
 lib/functions.php                     | 7 +++++++
 lib/navigation/CalendarNavigation.php | 6 +++++-
 lib/navigation/StudipNavigation.php   | 2 +-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/lib/functions.php b/lib/functions.php
index 20066c1cc3b..5f7cf8cdddf 100644
--- a/lib/functions.php
+++ b/lib/functions.php
@@ -1521,6 +1521,13 @@ function studip_default_exception_handler($exception) {
 
 
     try {
+        if (!isset($GLOBALS['user'])) {
+            $GLOBALS['user'] = new Seminar_User('nobody');
+            $GLOBALS['perm'] = new Seminar_Perm();
+        }
+        if (empty($_SESSION['_language'])) {
+            $_SESSION['_language'] = 'de_DE';
+        }
         $args = compact('exception', 'status');
         ob_start();
         echo $GLOBALS['template_factory']->render($template, $args, $layout);
diff --git a/lib/navigation/CalendarNavigation.php b/lib/navigation/CalendarNavigation.php
index badb47953aa..972f3f840e9 100644
--- a/lib/navigation/CalendarNavigation.php
+++ b/lib/navigation/CalendarNavigation.php
@@ -24,7 +24,11 @@ class CalendarNavigation extends Navigation
 
         parent::__construct(_('Planer'));
 
-        if (!$perm->have_perm('admin') && Config::get()->SCHEDULE_ENABLE) {
+        if (
+            isset($perm)
+            && !$perm->have_perm('admin')
+            && Config::get()->SCHEDULE_ENABLE
+        ) {
             $planerinfo = _('Stundenplan');
         } else {
             $planerinfo = _('Termine');
diff --git a/lib/navigation/StudipNavigation.php b/lib/navigation/StudipNavigation.php
index 5f73f288bc2..ff74dccbcac 100644
--- a/lib/navigation/StudipNavigation.php
+++ b/lib/navigation/StudipNavigation.php
@@ -127,7 +127,7 @@ class StudipNavigation extends Navigation
         }
 
         // admin page
-        if ($perm->have_perm('admin')) {
+        if (isset($perm) && $perm->have_perm('admin')) {
             $this->addSubNavigation('admin', new AdminNavigation());
         }
 
-- 
GitLab