From 0313846a9b5a28476c7a114b1b3a24367dec86c2 Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Fri, 17 Feb 2023 16:33:55 +0000
Subject: [PATCH] prevent php8 warning, fixes #2191

Closes #2191

Merge request studip/studip!1415
---
 app/controllers/admission/restricted_courses.php | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/app/controllers/admission/restricted_courses.php b/app/controllers/admission/restricted_courses.php
index b790088bcf1..e215fd0f886 100644
--- a/app/controllers/admission/restricted_courses.php
+++ b/app/controllers/admission/restricted_courses.php
@@ -37,7 +37,7 @@ class Admission_RestrictedCoursesController extends AuthenticatedController
 
         $sem_condition = "";
         foreach (words('current_institut_id sem_name_prefix') as $param) {
-            $this->$param = $_SESSION[get_class($this)][$param];
+            $this->$param = $_SESSION[get_class($this)][$param] ?? null;
         }
         if (Request::isPost()) {
             if (Request::submitted('choose_institut')) {
@@ -65,6 +65,10 @@ class Admission_RestrictedCoursesController extends AuthenticatedController
             $this->my_inst = $this->get_institutes($sem_condition);
         }
         $this->courses = $this->get_courses($sem_condition);
+
+        if (!isset($_SESSION[get_class($this)])) {
+            $_SESSION[get_class($this)] = [];
+        }
         foreach (words('current_institut_id sem_name_prefix') as $param) {
             $_SESSION[get_class($this)][$param] = $this->$param;
         }
-- 
GitLab