diff --git a/app/controllers/course/contentmodules.php b/app/controllers/course/contentmodules.php
index 06d46deab4c54206d8654d019671267b4e8eff84..04eb8464ddebdcb79ddcebf8812c12e8de794191 100644
--- a/app/controllers/course/contentmodules.php
+++ b/app/controllers/course/contentmodules.php
@@ -298,22 +298,22 @@ class Course_ContentmodulesController extends AuthenticatedController
                 'visibility'  => $visibility,
                 'active'      => (bool) $tool,
             ];
-            if ($metadata['icon_clickable']) {
+            if (!empty($metadata['icon_clickable'])) {
                 $list[$plugin_id]['icon'] = $metadata['icon_clickable'] instanceof Icon
                     ? $metadata['icon_clickable']->asImagePath()
                     : Icon::create($plugin->getPluginURL().'/'.$metadata['icon_clickable'])->asImagePath();
-            } elseif ($metadata['icon']) {
+            } elseif (!empty($metadata['icon'])) {
                 $list[$plugin_id]['icon'] = $metadata['icon'] instanceof Icon
                     ? $metadata['icon']->asImagePath()
                     : Icon::create($plugin->getPluginURL().'/'.$metadata['icon'])->asImagePath();
             } else {
                 $list[$plugin_id]['icon'] = null;
             }
-            $list[$plugin_id]['summary'] = $metadata['summary'];
+            $list[$plugin_id]['summary'] = $metadata['summary'] ?? null;
             $list[$plugin_id]['mandatory'] = $this->sem_class->isModuleMandatory(get_class($plugin));
             $list[$plugin_id]['highlighted'] = (bool) $plugin->isHighlighted();
             $list[$plugin_id]['highlight_text'] = $plugin->getHighlightText();
-            $list[$plugin_id]['category'] = $metadata['category'];
+            $list[$plugin_id]['category'] = $metadata['category'] ?? null;
         }
 
         return $list;
diff --git a/app/controllers/course/elearning.php b/app/controllers/course/elearning.php
index a8a7626bed8003277fad8c49699072e066327092..6e67b64a65318429b91aa81c55d9d00598e980e0 100644
--- a/app/controllers/course/elearning.php
+++ b/app/controllers/course/elearning.php
@@ -57,7 +57,10 @@ class Course_ElearningController extends AuthenticatedController
         if (!isset($GLOBALS['ELEARNING_INTERFACE_MODULES'][$this->cms_select])) {
             unset($this->cms_select);
         }
-        if ($this->seminar_id != $_SESSION['elearning_open_close']["id"]) {
+        if (
+            isset($_SESSION['elearning_open_close']['id'])
+            && $this->seminar_id !== $_SESSION['elearning_open_close']['id']
+        ) {
             unset($_SESSION['cache_data']);
             unset($_SESSION['elearning_open_close']);
         }
diff --git a/app/controllers/course/wizard.php b/app/controllers/course/wizard.php
index 009e0520892b6bb71bff02e07f5eb871815c6a6c..636d6eb4fe58fda738cbee66f1f4a61bdf7f277e 100644
--- a/app/controllers/course/wizard.php
+++ b/app/controllers/course/wizard.php
@@ -118,7 +118,7 @@ class Course_WizardController extends AuthenticatedController
             $values[$iterator->key()] = $iterator->current();
             $iterator->next();
         }
-        if ($this->steps[$step_number]['classname']) {
+        if (!empty($this->steps[$step_number]['classname'])) {
             $this->setStepValues($this->steps[$step_number]['classname'], $values);
         }
         // Back or forward button clicked -> set next step accordingly.
diff --git a/app/controllers/new_password.php b/app/controllers/new_password.php
index 5132c4804f2bb4b27d120e09054dcf3847a9f6b7..525d73b66232e56a9becba8f6d85b6c0f0e9552c 100644
--- a/app/controllers/new_password.php
+++ b/app/controllers/new_password.php
@@ -111,6 +111,7 @@ class NewPasswordController extends StudipController
             $password = Request::get('new_password');
             $confirm  = Request::get('new_password_confirm');
 
+            $errors = [];
             if (!$validator->ValidatePassword($password)) {
                 $errors[] = _('Das Passwort ist zu kurz. Es sollte mindestens 8 Zeichen lang sein.');
             } else if ($password !== $confirm) {
diff --git a/app/controllers/resources/room_request.php b/app/controllers/resources/room_request.php
index f128f23bae3017c42fe93ffc98a8200466dcd636..db892e09d2eafa07c6087b3db48718a689355638 100644
--- a/app/controllers/resources/room_request.php
+++ b/app/controllers/resources/room_request.php
@@ -1997,7 +1997,7 @@ class Resources_RoomRequestController extends AuthenticatedController
         if ($save_only) {
             // redirect to reload all infos and showing the most current ones
             $this->redirect('resources/room_request/resolve/' . $request_id);
-        } elseif (Request::isDialog()) {
+        } elseif (Request::isDialog() && Context::get()) {
             $this->response->add_header('X-Dialog-Execute', '{"func": "STUDIP.AdminCourses.App.loadCourse", "payload": "'.Context::get()->id.'"}');
         }
     }
diff --git a/app/views/course/contentmodules/info.php b/app/views/course/contentmodules/info.php
index 18d7ccf7363b6ed4e909e23f215744de081285a6..11bf9dc581a79e51a45be3e88692ae369e6f8fa7 100644
--- a/app/views/course/contentmodules/info.php
+++ b/app/views/course/contentmodules/info.php
@@ -29,8 +29,8 @@
                 </div>
             </div>
             <div class="content-modules-controls-vue-app" is="ContentModulesControl" module_id="<?= htmlReady($plugin->getPluginId()) ?>"></div>
-            <? $keywords = preg_split( "/;/", $metadata['keywords'], -1, PREG_SPLIT_NO_EMPTY) ?>
-            <? if (count($keywords)) : ?>
+            <? $keywords = preg_split( "/;/", $metadata['keywords'] ?? '', -1, PREG_SPLIT_NO_EMPTY) ?>
+            <? if (count($keywords) > 0) : ?>
             <ul class="keywords">
                 <? foreach ($keywords as $keyword) : ?>
                 <li>
diff --git a/lib/classes/coursewizardsteps/BasicDataWizardStep.php b/lib/classes/coursewizardsteps/BasicDataWizardStep.php
index ce3b57f0752b81262c3d12bbbc62f823edd78d3c..100786b057392784af39aeccd231360bebdb393c 100644
--- a/lib/classes/coursewizardsteps/BasicDataWizardStep.php
+++ b/lib/classes/coursewizardsteps/BasicDataWizardStep.php
@@ -344,13 +344,13 @@ class BasicDataWizardStep implements CourseWizardStep
         if (!trim($values['name'])) {
             $errors[] = _('Bitte geben Sie den Namen der Veranstaltung an.');
         }
-        if ($values['number'] != '') {
+        if (!empty($values['number'])) {
             $course_number_format = Config::get()->COURSE_NUMBER_FORMAT;
             if ($course_number_format && !preg_match('/^' . $course_number_format . '$/', $values['number'])) {
                 $errors[] = _('Die Veranstaltungsnummer hat ein ungültiges Format.');
             }
         }
-        if (!$values['lecturers']) {
+        if (empty($values['lecturers'])) {
             $errors[] = sprintf(
                 _('Bitte tragen Sie mindestens eine Person als %s ein.'),
                 htmlReady(get_title_for_status('dozent', 1, $values['coursetype']))
@@ -411,7 +411,7 @@ class BasicDataWizardStep implements CourseWizardStep
 
         $course->status = $values['coursetype'];
         $course->name = new I18NString($values['name'], $values['name_i18n'] ?? []);
-        $course->veranstaltungsnummer = $values['number'];
+        $course->veranstaltungsnummer = $values['number'] ?? null;
         $course->beschreibung = new I18NString($values['description'], $values['description_i18n'] ?? []);
         $course->start_semester = Semester::findByTimestamp($values['start_time']);
         $course->institut_id = $values['institute'];
diff --git a/lib/elearning/ELearningUtils.class.php b/lib/elearning/ELearningUtils.class.php
index 30c40c401a2e898d5faeac921f3ae40044a98fd8..d027e37210263936a4690a88916a5782dacf1639 100644
--- a/lib/elearning/ELearningUtils.class.php
+++ b/lib/elearning/ELearningUtils.class.php
@@ -472,6 +472,7 @@ class ELearningUtils
                           FROM object_contentmodules
                           WHERE module_type = 'crs' AND object_id = " . $db->quote($sem_id))
                         ->fetchAll(PDO::FETCH_ASSOC);
+        $courses = [];
         foreach ($rs as $row) {
             $courses[$row['system_type']] = $row['module_id'];
         }
@@ -479,23 +480,26 @@ class ELearningUtils
         $connected_courses = [
             'courses' => [],
         ];
-        if (is_array($courses))
-            foreach ($courses as $system_type => $crs_id)
+        if (is_array($courses)) {
+            foreach ($courses as $system_type => $crs_id) {
                 if (self::isCMSActive($system_type)) {
                     self::loadClass($system_type);
                     $connected_courses['courses'][$system_type] = [
-                        'url' => URLHelper::getLink($connected_cms[$system_type]->link->cms_link . '?client_id=' . $connected_cms[$system_type]->getClientId() . '&cms_select=' . $system_type . '&ref_id=' . $crs_id . '&type=crs&target=start'),
-                        'cms_name' => $connected_cms[$system_type]->getName()];
+                        'url'      => URLHelper::getLink($connected_cms[$system_type]->link->cms_link . '?client_id=' . $connected_cms[$system_type]->getClientId() . '&cms_select=' . $system_type . '&ref_id=' . $crs_id . '&type=crs&target=start'),
+                        'cms_name' => $connected_cms[$system_type]->getName()
+                    ];
                     // gegebenenfalls zugeordnete Module aktualisieren
                     if (Request::option('update')) {
                         if ((method_exists($connected_cms[$system_type], "updateConnections"))) {
-                            $connected_cms[$system_type]->updateConnections( $crs_id );
+                            $connected_cms[$system_type]->updateConnections($crs_id);
                         }
                     }
                     if (method_exists($connected_cms[$system_type]->permissions, 'CheckUserPermissions')) {
                         $connected_cms[$system_type]->permissions->CheckUserPermissions($crs_id);
                     }
                 }
+            }
+        }
 
         if ($connected_courses['courses']) {
             if (count($connected_courses['courses']) > 1) {
diff --git a/lib/filesystem/PublicFolder.php b/lib/filesystem/PublicFolder.php
index 15fdf34cd28831e5a58704ce77070d7c62618273..6b06ac905a42ce67410f49e39d64207691f6d8cc 100644
--- a/lib/filesystem/PublicFolder.php
+++ b/lib/filesystem/PublicFolder.php
@@ -60,7 +60,7 @@ class PublicFolder extends StandardFolder
     public function __get($attribute)
     {
         if ($attribute === 'viewable') {
-            return $this->folderdata['data_content']['viewable'];
+            return !empty($this->folderdata['data_content']['viewable']);
         }
         return $this->folderdata[$attribute];
     }
diff --git a/lib/models/Course.class.php b/lib/models/Course.class.php
index e16df06e5f33b9191a650b363348b823ba541451..4c471ea64e47dc212d2794872417d8898a4f4409 100644
--- a/lib/models/Course.class.php
+++ b/lib/models/Course.class.php
@@ -341,7 +341,7 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe
     {
         $end_semester = $this->semesters->last();
         $start_semester = $this->semesters->first();
-        if ($start_semester->id === $semester->id) {
+        if ($start_semester && $start_semester->id === $semester->id) {
             return;
         }
         if ($end_semester) {
@@ -369,7 +369,9 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe
     {
         $end_semester = $this->semesters->last();
         $start_semester = $this->semesters->first();
-        if ((is_null($end_semester) && is_null($semester)) || ($end_semester->id === $semester->id)) {
+        if (
+            (is_null($end_semester) && is_null($semester))
+            || ($end_semester && $semester && $end_semester->id === $semester->id)) {
             return;
         }
         if ($start_semester) {
diff --git a/lib/models/OERMaterial.php b/lib/models/OERMaterial.php
index ea36035d78ea3a45797814566c3dd0fdae204be1..f0e101d94df3d5d9aaba0794cfbe3206b314c195 100644
--- a/lib/models/OERMaterial.php
+++ b/lib/models/OERMaterial.php
@@ -390,8 +390,10 @@ class OERMaterial extends SimpleORMap
         }
         $url = $this->getDownloadUrl();
         $headers = get_headers($url, true, get_default_http_stream_context($url));
-        if ($headers['Content-Disposition']
-            && substr($headers['Content-Disposition'], 0, strlen('attachment')) === 'attachment') {
+        if (
+            !empty($headers['Content-Disposition'])
+            && substr($headers['Content-Disposition'], 0, strlen('attachment')) === 'attachment'
+        ) {
             //in this case the server forces to download the document and we cannot display it in an iframe:
             return false;
         }
diff --git a/lib/models/SimpleCollection.class.php b/lib/models/SimpleCollection.class.php
index 11dd29653017b3ce74aa068e5862ac18c8918777..42285998aadcef9f8bf171b058b3e9f67aa69b2a 100644
--- a/lib/models/SimpleCollection.class.php
+++ b/lib/models/SimpleCollection.class.php
@@ -592,7 +592,7 @@ class SimpleCollection extends StudipArrayObject
     public function val($key)
     {
         $first = $this->first();
-        return $first[$key] ?: null;
+        return $first[$key] ?? null;
     }
 
     /**
diff --git a/lib/plugins/core/CorePlugin.php b/lib/plugins/core/CorePlugin.php
index 0bba2897b13a0c6310ea9d5ddd4a3838111bc884..7f1aaed7c5478aa0d392393499b61fcea51fc2c0 100644
--- a/lib/plugins/core/CorePlugin.php
+++ b/lib/plugins/core/CorePlugin.php
@@ -64,10 +64,10 @@ abstract class CorePlugin
     {
         $metadata = $this->getMetadata();
         $language = getUserLanguage(User::findCurrent()->id);
-        if ($metadata['descriptionlong_' . $language]) {
+        if (!empty($metadata['descriptionlong_' . $language])) {
             return $metadata['descriptionlong_' . $language];
         }
-        if ($metadata['description_' . $language]) {
+        if (!empty($metadata['description_' . $language])) {
             return $metadata['description_' . $language];
         }
         $description = $metadata['descriptionlong'] ?? $metadata['description'];
diff --git a/lib/plugins/core/StudIPPlugin.class.php b/lib/plugins/core/StudIPPlugin.class.php
index a3dacb6b8b098ddc00af76f2fb0f69c9d8fc3473..be2c776b2aed2c9903496bb56eac9748715cfd37 100644
--- a/lib/plugins/core/StudIPPlugin.class.php
+++ b/lib/plugins/core/StudIPPlugin.class.php
@@ -89,10 +89,10 @@ abstract class StudIPPlugin
     {
         $metadata = $this->getMetadata();
         $language = getUserLanguage(User::findCurrent()->id);
-        if ($metadata['descriptionlong_' . $language]) {
+        if (!empty($metadata['descriptionlong_' . $language])) {
             return $metadata['descriptionlong_' . $language];
         }
-        if ($metadata['description_' . $language]) {
+        if (!empty($metadata['description_' . $language])) {
             return $metadata['description_' . $language];
         }
         $description = $metadata['descriptionlong'] ?? $metadata['description'];
diff --git a/lib/plugins/engine/PluginManager.class.php b/lib/plugins/engine/PluginManager.class.php
index 7fb69bc8e3fac649b0425845144b0f4ec80e3ef2..39f4e870c4e344d601b50667fb8961e610795187 100644
--- a/lib/plugins/engine/PluginManager.class.php
+++ b/lib/plugins/engine/PluginManager.class.php
@@ -87,9 +87,9 @@ class PluginManager
                 'automatic_update_url'    => $plugin['automatic_update_url'],
                 'automatic_update_secret' => $plugin['automatic_update_secret'],
                 'description'             => $plugin['description'],
-                'description_mode'         => $plugin['description_mode'],
-                'highlight_until'         => $plugin['highlight_until'],
-                'highlight_text'          => $plugin['highlight_text']
+                'description_mode'        => $plugin['description_mode'] ?? null,
+                'highlight_until'         => $plugin['highlight_until'] ?? null,
+                'highlight_text'          => $plugin['highlight_text'] ?? null,
             ];
         }
     }
diff --git a/lib/visual.inc.php b/lib/visual.inc.php
index 8503a5c7f794aea5bb9546267d8cdbf67d0ce94d..2b37a64a17b1be9d81fd005d0204a313cd159db3 100644
--- a/lib/visual.inc.php
+++ b/lib/visual.inc.php
@@ -399,14 +399,13 @@ function symbol ($text = '')
 function mila ($titel, $size = 60) {
     global $auth;
 
-    if ($auth->auth["jscript"] AND $size == 60) {
+    if (!empty($auth->auth['jscript']) && $size == 60) {
         //hier wird die maximale Laenge berechnet, nach der Abgeschnitten wird (JS dynamisch)
-        if (mb_strlen ($titel) >$auth->auth["xres"] / 13)
-            $titel=mb_substr($titel, 0, $auth->auth["xres"] / 13)."... ";
-    }
-    else {
-        if (mb_strlen ($titel) >$size)
-            $titel=mb_substr($titel, 0, $size)."... ";
+        if (mb_strlen($titel) > $auth->auth['xres'] / 13) {
+            $titel = mb_substr($titel, 0, $auth->auth['xres'] / 13) . '... ';
+        }
+    } elseif (mb_strlen ($titel) >$size) {
+        $titel = mb_substr($titel, 0, $size) . '... ';
     }
     return $titel;
 }