From 9e13d2f5fa4726b54efe8ad046d0b53aadb543bf Mon Sep 17 00:00:00 2001
From: Moritz Strohm <strohm@data-quest.de>
Date: Wed, 28 Sep 2022 12:32:56 +0000
Subject: [PATCH] fix for BIESt #1104

Merge request studip/studip!674
---
 app/controllers/search/courses.php            |  8 +-
 app/controllers/search/module.php             | 11 +--
 app/controllers/search/studiengaenge.php      |  2 +-
 app/views/search/globalsearch/index.php       |  2 +-
 app/views/search/stgtable/index.php           |  4 +-
 app/views/search/studiengaenge/verlauf.php    |  2 +-
 lib/classes/BreadCrumb.class.php              |  1 +
 lib/classes/DbSnapshot.class.php              |  3 +
 lib/classes/QuickSearch.class.php             |  7 +-
 lib/classes/SemBrowse.class.php               | 50 ++++++------
 lib/classes/StudipForm.class.php              | 37 ++++-----
 .../StudipSemRangeTreeViewSimple.class.php    |  6 +-
 lib/classes/StudipSemSearch.class.php         |  4 +-
 lib/classes/StudipSemSearchHelper.class.php   | 13 ++--
 lib/classes/StudipSemTree.class.php           |  5 +-
 lib/classes/StudipSemTreeViewSimple.class.php |  6 +-
 lib/classes/TreeAbstract.class.php            |  9 ++-
 .../globalsearch/GlobalSearchCourses.php      | 15 +++-
 .../globalsearch/GlobalSearchForum.php        |  4 +-
 .../globalsearch/GlobalSearchModule.php       |  2 +-
 .../globalsearch/GlobalSearchMyCourses.php    | 10 ++-
 .../globalsearch/GlobalSearchUsers.php        |  1 +
 lib/classes/searchtypes/SearchType.class.php  |  2 +
 lib/classes/sidebar/ClipboardWidget.class.php |  3 +-
 .../sidebar/ResourceTreeWidget.class.php      |  1 +
 .../sidebar/RoomSearchWidget.class.php        |  2 +-
 lib/models/Modulteil.php                      |  4 +-
 lib/models/SimpleCollection.class.php         |  4 +-
 lib/models/resources/Location.class.php       | 78 +++++++++----------
 lib/raumzeit/SingleDate.class.php             |  4 +-
 templates/sidebar/room-clipboard-item.php     |  6 +-
 templates/sidebar/room-search-widget.php      | 30 +++----
 vendor/write_excel/OLEwriter.php              |  4 +-
 vendor/write_excel/Parser.php                 | 14 ++--
 34 files changed, 200 insertions(+), 154 deletions(-)

diff --git a/app/controllers/search/courses.php b/app/controllers/search/courses.php
index 9a3294c522c..536c361ae41 100644
--- a/app/controllers/search/courses.php
+++ b/app/controllers/search/courses.php
@@ -30,12 +30,12 @@ class Search_CoursesController extends AuthenticatedController
         // activate navigation item
         $nav_options = Config::get()->COURSE_SEARCH_NAVIGATION_OPTIONS;
         URLHelper::bindLinkParam('option', $this->nav_option);
-        if ($nav_options[$this->nav_option]
+        if (!empty($nav_options[$this->nav_option])
                 && Navigation::hasItem('/search/courses/' . $this->nav_option)) {
             Navigation::activateItem('/search/courses/' . $this->nav_option);
         } else {
             URLHelper::removeLinkParam('option');
-            $level = Request::get('level', $_SESSION['sem_browse_data']['level']);
+            $level = Request::get('level', $_SESSION['sem_browse_data']['level'] ?? '');
             $default_option = SemBrowse::getSearchOptionNavigation('sidebar');
             if (!$level) {
                 PageLayout::setTitle(_($default_option->getTitle()));
@@ -74,7 +74,7 @@ class Search_CoursesController extends AuthenticatedController
         $sidebar = Sidebar::get();
 
         // add search options to sidebar
-        $level = Request::get('level', $_SESSION['sem_browse_data']['level']);
+        $level = Request::get('level', $_SESSION['sem_browse_data']['level'] ?? '');
 
         $widget = new OptionsWidget();
         $widget->setTitle(_('Suche'));
@@ -114,7 +114,7 @@ class Search_CoursesController extends AuthenticatedController
         }
 
         // show information about course class if class was changed
-        $class = $GLOBALS['SEM_CLASS'][$_SESSION['sem_browse_data']['show_class']];
+        $class = $GLOBALS['SEM_CLASS'][$_SESSION['sem_browse_data']['show_class']] ?? null;
         if (is_object($class) && $class->countSeminars() > 0) {
             if (trim($GLOBALS['SEM_CLASS'][$_SESSION['sem_browse_data']['show_class']]['description'])) {
                 PageLayout::postInfo(sprintf(_('Gewählte Veranstaltungsklasse <i>%1s</i>: %2s'),
diff --git a/app/controllers/search/module.php b/app/controllers/search/module.php
index 082ad2164f7..38106ea7d92 100644
--- a/app/controllers/search/module.php
+++ b/app/controllers/search/module.php
@@ -147,14 +147,14 @@ class Search_ModuleController extends MVVController
         $sidebar->addWidget($widget, 'sem_filter');
 
         $this->input_search = $this->sterm;
-        $this->result_count = is_array($this->search_result['Modul']) ? count($this->search_result['Modul']) : 0;
+        $this->result_count = (!empty($this->search_result['Modul']) && is_array($this->search_result['Modul'])) ? count($this->search_result['Modul']) : 0;
 
         $drill_down['studiengaenge']['objects'] =
-                $this->drilldown_studiengaenge($this->search_result['Modul']);
+                $this->drilldown_studiengaenge($this->search_result['Modul'] ?? []);
         $drill_down['faecher']['objects'] =
-                $this->drilldown_faecher($this->search_result['Modul']);
+                $this->drilldown_faecher($this->search_result['Modul'] ?? []);
         $drill_down['institutes']['objects'] =
-                $this->drilldown_institutes($this->search_result['Modul']);
+                $this->drilldown_institutes($this->search_result['Modul'] ?? []);
         if (count($drill_down['institutes']['objects'])
                 || count($drill_down['studiengaenge']['objects'])
                 || count($drill_down['faecher']['objects'])) {
@@ -214,7 +214,8 @@ class Search_ModuleController extends MVVController
         }
 
         $this->module = [];
-        if (is_array($this->search_result['Modul'])
+        $this->count = 0;
+        if (!empty($this->search_result['Modul']) && is_array($this->search_result['Modul'])
                 && count($this->search_result['Modul'])) {
             if (!empty($this->drill_down_type) && !empty($this->drill_down_id)) {
                 $this->search_result['Modul'] = $this->filter_modules(
diff --git a/app/controllers/search/studiengaenge.php b/app/controllers/search/studiengaenge.php
index 1bd94a47db2..91d999a126e 100644
--- a/app/controllers/search/studiengaenge.php
+++ b/app/controllers/search/studiengaenge.php
@@ -257,7 +257,7 @@ class Search_StudiengaengeController extends MVVController
 
                     $start_sem = Semester::find($abschnitt_modul->modul->start);
                     $end_sem = Semester::find($abschnitt_modul->modul->end);
-                    if ($start_sem->beginn > $this->active_sem->beginn || ($this->active_sem->ende > $end_sem->ende && $end_sem != null)) {
+                    if (($start_sem && $start_sem->beginn > $this->active_sem->beginn) || ($end_sem && $this->active_sem->ende > $end_sem->ende)) {
                        continue;
                     }
 
diff --git a/app/views/search/globalsearch/index.php b/app/views/search/globalsearch/index.php
index e85aa8f7d86..637873e20bf 100644
--- a/app/views/search/globalsearch/index.php
+++ b/app/views/search/globalsearch/index.php
@@ -1,7 +1,7 @@
 <form class="default" onsubmit="return false;" autocomplete="off">
     <div id="div-search-input" class="input-group files-search">
         <input type="text" autofocus name="searchtext" id="search-input"
-            value="<?= htmlReady($_SESSION['search_text']) ?>"
+            value="<?= htmlReady($_SESSION['search_text'] ?? '') ?>"
             placeholder="<?= _('Was suchen Sie?') ?>">
 
         <span class="input-group-append">
diff --git a/app/views/search/stgtable/index.php b/app/views/search/stgtable/index.php
index 1e54e065265..f9d82608a24 100644
--- a/app/views/search/stgtable/index.php
+++ b/app/views/search/stgtable/index.php
@@ -18,7 +18,7 @@
             <tr>
                 <td><?= htmlReady($name) ?></td>
                 <? foreach ($kategorien as $kat_id => $kategorie): ?>
-                    <? if ($stg[$kat_id]) : ?>
+                    <? if (!empty($stg[$kat_id])) : ?>
                 <td style="text-align: center;">
                     <a href="<?= $controller->action_link('studiengang', $stg[$kat_id]) ?>"><?= Icon::create('info-circle-full', 'clickable', ['title' => _('Studiengang anzeigen')])->asImg(); ?></a>
                 </td>
@@ -29,4 +29,4 @@
             </tr>
         <? endforeach; ?>
     </tbody>
-</table>
\ No newline at end of file
+</table>
diff --git a/app/views/search/studiengaenge/verlauf.php b/app/views/search/studiengaenge/verlauf.php
index 2e50d4c915e..431d94d489f 100644
--- a/app/views/search/studiengaenge/verlauf.php
+++ b/app/views/search/studiengaenge/verlauf.php
@@ -6,7 +6,7 @@
     <table class="mvv-modul-details default nohover">
         <caption>
             <?= htmlReady($studiengangTeilName) ?>
-    <? if ($studiengang && $stgTeilBez) : ?>
+    <? if ($studiengang && !empty($stgTeilBez)) : ?>
         <h3>
             <?= sprintf(_('%s im Studiengang %s'), htmlReady($stgTeilBez->getDisplayName()), htmlReady($studiengang->getDisplayName(ModuleManagementModel::DISPLAY_ABSCHLUSS))) ?>
             <? if (Config::get()->ENABLE_STUDYCOURSE_INFO_PAGE) : ?>
diff --git a/lib/classes/BreadCrumb.class.php b/lib/classes/BreadCrumb.class.php
index 386da4f0446..73a2086e52a 100644
--- a/lib/classes/BreadCrumb.class.php
+++ b/lib/classes/BreadCrumb.class.php
@@ -37,6 +37,7 @@ class BreadCrumb
     public function append($object, $action)
     {
         $trail = $this->getTrail();
+        $id = '';
         if (is_object($object)) {
             $type = get_class($object);
             $id = $object->id;
diff --git a/lib/classes/DbSnapshot.class.php b/lib/classes/DbSnapshot.class.php
index 8735fa03e19..dfb4f896686 100644
--- a/lib/classes/DbSnapshot.class.php
+++ b/lib/classes/DbSnapshot.class.php
@@ -300,6 +300,9 @@ class DbSnapshot
         for ($i = 0; $i < $this->numRows; ++$i) {
             for ($j = 0; $j < $num_fields; ++$j) {
                 if ($fieldlist[$j] != $group_by_field) {
+                    if (empty($ret[$this->result[$i][$group_by_field]][$fieldlist[$j]][$this->result[$i][$fieldlist[$j]]])) {
+                        $ret[$this->result[$i][$group_by_field]][$fieldlist[$j]][$this->result[$i][$fieldlist[$j]]] = 0;
+                    }
                     ++$ret[$this->result[$i][$group_by_field]][$fieldlist[$j]][$this->result[$i][$fieldlist[$j]]];
                 }
             }
diff --git a/lib/classes/QuickSearch.class.php b/lib/classes/QuickSearch.class.php
index 6b239de1b02..69a80f7c247 100644
--- a/lib/classes/QuickSearch.class.php
+++ b/lib/classes/QuickSearch.class.php
@@ -203,9 +203,9 @@ class QuickSearch
         if (isset($design['width'])) {
             $this->box_width = $design['width'];
         }
-        $this->box_align = $design['align'] ? $design['align'] : "right";
-        $this->search_button_name = $design['search_button_name'];
-        $this->reset_button_name = $design['reset_button_name'];
+        $this->box_align = $design['align'] ?? "right";
+        $this->search_button_name = $design['search_button_name'] ?? '';
+        $this->reset_button_name = $design['reset_button_name'] ?? '';
         return $this;
     }
 
@@ -373,6 +373,7 @@ class QuickSearch
             $template->set_attribute('withButton', $this->withButton);
             $template->set_attribute('box_align', $this->box_align);
             $template->set_attribute('box_width', $this->box_width);
+            $template->set_attribute('inputStyle', $this->inputStyle ?? '');
             $template->set_attribute('beschriftung', $this->beschriftung());
             $template->set_attribute('name', $this->name);
             $template->set_attribute('defaultID', $this->defaultID);
diff --git a/lib/classes/SemBrowse.class.php b/lib/classes/SemBrowse.class.php
index 29dcd387845..12de227fff1 100644
--- a/lib/classes/SemBrowse.class.php
+++ b/lib/classes/SemBrowse.class.php
@@ -107,10 +107,10 @@ class SemBrowse {
             $this->sem_number = false;
         }
 
-        $sem_status = (is_array($this->sem_browse_data['sem_status'])) ? $this->sem_browse_data['sem_status'] : false;
+        $sem_status = (!empty($this->sem_browse_data['sem_status']) && is_array($this->sem_browse_data['sem_status'])) ? $this->sem_browse_data['sem_status'] : false;
 
         if ($this->sem_browse_data['level'] == 'vv') {
-            if (!$this->sem_browse_data['start_item_id']){
+            if (empty($this->sem_browse_data['start_item_id'])) {
                 $this->sem_browse_data['start_item_id'] = 'root';
             }
             $this->sem_tree = new StudipSemTreeViewSimple(
@@ -282,7 +282,7 @@ class SemBrowse {
         $db_view = DbView::getView('sem_tree');
         $db_view->params[0] = $inst_ids;
         $db_view->params[1] = (is_object($GLOBALS['perm']) && $GLOBALS['perm']->have_perm(Config::get()->SEM_VISIBILITY_PERM)) ? '' : ' AND c.visible=1';
-        $db_view->params[1] .= is_array($this->sem_browse_data['sem_status'])
+        $db_view->params[1] .= !empty($this->sem_browse_data['sem_status']) && is_array($this->sem_browse_data['sem_status'])
                 ? " AND c.status IN('" . join("','", $this->sem_browse_data['sem_status']) ."')"
                 : '';
         $db_view->params[2] = is_array($this->sem_number)
@@ -378,13 +378,13 @@ class SemBrowse {
         if ($this->sem_browse_data['level'] == 'vv') {
             echo "\n" . '<caption class="legend">'._('Studienbereiche').'<caption>';
             echo "\n" . '<tr><td style="text-align: center">';
-            $this->sem_tree->show_entries = $this->sem_browse_data['show_entries'];
+            $this->sem_tree->show_entries = $this->sem_browse_data['show_entries'] ?? false;
             $this->sem_tree->showSemTree($start_id);
         }
         if ($this->sem_browse_data['level'] == 'ev') {
             echo "\n" . '<caption class="legend">'._('Einrichtungen').'<caption>';
             echo "\n" . '<tr><td style="text-align: center">';
-            $this->range_tree->show_entries = $this->sem_browse_data['show_entries'];
+            $this->range_tree->show_entries = $this->sem_browse_data['show_entries'] ?? false;
             $this->range_tree->showSemRangeTree($start_id);
         }
 
@@ -407,7 +407,7 @@ class SemBrowse {
                 $this->sem_tree = new StudipSemTreeViewSimple(
                         $this->sem_browse_data['start_item_id'],
                         $this->sem_number,
-                        is_array($this->sem_browse_data['sem_status'])
+                        !empty($this->sem_browse_data['sem_status']) && is_array($this->sem_browse_data['sem_status'])
                             ? $this->sem_browse_data['sem_status'] : false,
                         !(is_object($GLOBALS['perm']) && $GLOBALS['perm']->have_perm(Config::get()->SEM_VISIBILITY_PERM)));
             }
@@ -464,6 +464,7 @@ class SemBrowse {
             echo '</table>';
         } elseif ($this->search_obj->search_button_clicked
                 && !$this->search_obj->new_search_button_clicked) {
+            $details = [];
             if ($this->search_obj->found_rows === false) {
                 $details = [_('Der Suchbegriff fehlt oder ist zu kurz')];
             }
@@ -721,7 +722,7 @@ class SemBrowse {
         $snap = new DbSnapshot($db);
         $group_field = $this->group_by_fields[$this->sem_browse_data['group_by']]['group_field'];
         $data_fields[0] = 'Seminar_id';
-        if ($this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field']) {
+        if (!empty($this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field'])) {
             $data_fields[1] = $this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field'];
         }
         if($user->id == 'nobody' && $snap->numRows == 0){
@@ -768,7 +769,7 @@ class SemBrowse {
                     }
                 }
             }
-            if (is_array($tmp_group_by_data)) {
+            if (!empty($tmp_group_by_data) && is_array($tmp_group_by_data)) {
                 if ($this->sem_number !== false) {
                     unset($group_by_data);
                 }
@@ -845,7 +846,7 @@ class SemBrowse {
          */
         if (($GLOBALS['perm']->have_perm(Config::get()->SEM_VISIBILITY_PERM)
                 || key($sem_data[$seminar_id]['visible']) == 1)
-                && (!$sem_data[key($sem_data[$seminar_id]['parent_course'])]
+                && (empty($sem_data[key($sem_data[$seminar_id]['parent_course'])])
                         || $child)) {
             // create instance of seminar-object
             $seminar_obj = new Seminar($seminar_id);
@@ -934,10 +935,13 @@ class SemBrowse {
                         . htmlReady(mb_substr($seminar_obj->description, 0, 100))
                         . '</div>';
             } else {
-                $temp_turnus_string = $seminar_obj->getDatesExport([
-                    'short' => true,
-                    'shrink' => true,
-                ]);
+                $temp_turnus_string = $seminar_obj->getDatesExport(
+                    [
+                        'short' => true,
+                        'shrink' => true,
+                        'semester_id' => ''
+                    ]
+                );
                 //Shorten, if string too long (add link for details.php)
                 if (mb_strlen($temp_turnus_string) > 70) {
                     $temp_turnus_string = htmlReady(mb_substr($temp_turnus_string, 0, mb_strpos(mb_substr($temp_turnus_string, 70, mb_strlen($temp_turnus_string)), ',') + 71));
@@ -1241,16 +1245,16 @@ class SemBrowse {
      */
     public static function transferSessionData()
     {
-        if (Request::option('reset_all')) {
-            $_SESSION['sem_browse_data'] = null;
+        if (empty($_SESSION['sem_browse_data']) || Request::option('reset_all')) {
+            $_SESSION['sem_browse_data'] = [];
         }
 
         $_SESSION['sem_browse_data']['qs_choose'] = Request::get('search_sem_qs_choose',
-                $_SESSION['sem_browse_data']['qs_choose']);
+                $_SESSION['sem_browse_data']['qs_choose'] ?? null);
 
         // simulate button clicked if semester was changed
-        if (Request::option('search_sem_sem', $_SESSION['sem_browse_data']['default_sem'])
-                != $_SESSION['sem_browse_data']['default_sem']) {
+        $old_default_sem = $_SESSION['sem_browse_data']['default_sem'] ?? null;
+        if (Request::option('search_sem_sem', $old_default_sem) != $old_default_sem) {
             $_SESSION['sem_browse_data']['default_sem'] = Request::option('search_sem_sem');
             if ($_SESSION['sem_browse_data']['sset']) {
                 Request::set('search_sem_quick_search_parameter', $_SESSION['sem_browse_data']['sset']);
@@ -1267,8 +1271,8 @@ class SemBrowse {
         }
 
         // simulate button clicked if class was changed
-        if (Request::option('show_class', $_SESSION['sem_browse_data']['show_class'])
-                != $_SESSION['sem_browse_data']['show_class']) {
+        $old_show_class = $_SESSION['sem_browse_data']['show_class'] ?? null;
+        if (Request::option('show_class', $old_show_class) != $old_show_class) {
             $_SESSION['sem_browse_data']['show_class'] = Request::option('show_class');
 
             if ($_SESSION['sem_browse_data']['show_class']
@@ -1300,9 +1304,9 @@ class SemBrowse {
                         ?: 'all';
         }
         $_SESSION['sem_browse_data']['show_class'] =
-                $_SESSION['sem_browse_data']['show_class'] ?: 'all';
+                $_SESSION['sem_browse_data']['show_class'] ?? 'all';
         $_SESSION['sem_browse_data']['group_by'] =
-                $_SESSION['sem_browse_data']['group_by'] ?: '0';
+                $_SESSION['sem_browse_data']['group_by'] ?? '0';
     }
 
     /**
@@ -1386,7 +1390,7 @@ class SemBrowse {
 	    $stmt->execute([$seminar_id]);
 	    $result = $stmt->fetch();
 
-        if ($result['types']) {
+        if (!empty($result['types'])) {
             if ($result['type_locked']) {
                 return 2;
             }
diff --git a/lib/classes/StudipForm.class.php b/lib/classes/StudipForm.class.php
index fd76fee9879..88c36fe9b6b 100644
--- a/lib/classes/StudipForm.class.php
+++ b/lib/classes/StudipForm.class.php
@@ -87,7 +87,7 @@ class StudipForm {
         }
         if ($this->isSended()){
             foreach ($this->form_fields as $name => $foo){
-                if (!$foo['disabled']){
+                if (empty($foo['disabled'])) {
                     if ( ($field_value = Request::get($this->form_name . "_" . $name)) !== null) {
                             $new_form_values[$name] = trim($field_value);
                     } elseif ( is_array($field_value = Request::getArray($this->form_name . "_" . $name))) {
@@ -100,7 +100,7 @@ class StudipForm {
                 }
             }
             foreach ($this->form_fields as $name => $value){
-                if (!$value['disabled']){
+                if (empty($value['disabled'])) {
                     if ($value['type'] == 'combo'){
                         if ($this->form_values[$name] != $new_form_values[$value['text']]){ //textfeld wurde verändert
                             $new_form_values[$name] = $new_form_values[$value['text']];
@@ -129,7 +129,8 @@ class StudipForm {
                         $new_form_values[$name] = Request::int($this->form_name . "_" . $name, 0);
                     }
                     if ( (isset($this->form_values[$name]) && $this->form_values[$name] != $new_form_values[$name])
-                        || (!isset($this->form_values[$name]) && $new_form_values[$name] != $this->form_fields[$name]['default_value']) ){
+                        || (!isset($this->form_values[$name]) && !empty($new_form_values[$name]) && !empty($this->form_fields[$name]['default_value'])
+                            && $new_form_values[$name] != $this->form_fields[$name]['default_value']) ){
                         $this->value_changed[$name] = true;
                     }
                 }
@@ -162,22 +163,22 @@ class StudipForm {
         if (!$attributes){
             $attributes = $this->field_attributes_default;
         }
-        if (!$default){
-            if (isset($this->form_values[$name])){
+        if (empty($default)) {
+            if (isset($this->form_values[$name])) {
                 $default = $this->form_values[$name];
             } else {
-                $default = $this->form_fields[$name]['default_value'];
+                $default = $this->form_fields[$name]['default_value'] ?? '';
             }
         }
-        if (is_array($this->form_fields[$name]['attributes'])){
+        if (!empty($this->form_fields[$name]['attributes']) && is_array($this->form_fields[$name]['attributes'])) {
             $attributes = array_merge((array)$attributes, (array)$this->form_fields[$name]['attributes']);
         }
 
-        if ($this->form_fields[$name]['disabled']){
+        if (!empty($this->form_fields[$name]['disabled'])) {
             $attributes['disabled'] = 'disabled';
         }
 
-        if ($this->form_fields[$name]['required']){
+        if (!empty($this->form_fields[$name]['required'])) {
             $attributes['required'] = 'required';
         }
 
@@ -281,7 +282,7 @@ class StudipForm {
 
     function getFormFieldSelect($name, $attributes, $default){
         $ret = "\n<select name=\"{$this->form_name}_{$name}";
-        if ($this->form_fields[$name]['multiple']){
+        if (!empty($this->form_fields[$name]['multiple'])){
             $ret .= "[]\" multiple ";
         } else {
             $ret .= "\" ";
@@ -291,7 +292,7 @@ class StudipForm {
         if ($default === false){
             $default = $this->form_fields[$name]['default_value'];
         }
-        if (is_array($this->form_fields[$name]['options'])){
+        if (!empty($this->form_fields[$name]['options']) && is_array($this->form_fields[$name]['options'])){
             $options = $this->form_fields[$name]['options'];
         } else if ($this->form_fields[$name]['options_callback']){
             $options = call_user_func($this->form_fields[$name]['options_callback'],$this,$name);
@@ -299,13 +300,13 @@ class StudipForm {
         for ($i = 0; $i < count($options); ++$i){
             $options_name = (is_array($options[$i])) ? $options[$i]['name'] : $options[$i];
             $options_value = (is_array($options[$i])) ? $options[$i]['value'] : $options[$i];
-            $options_attributes = (is_array($options[$i])) ? $options[$i]['attributes'] : [];
+            $options_attributes = $options[$i]['attributes'] ?? [];
             $selected = false;
             if ((is_array($default) && in_array("" . $options_value, $default))
             || (!is_array($default) && ($default == "" . $options_value))){
                 $selected = true;
             }
-            if ($this->form_fields[$name]['max_length']){
+            if (!empty($this->form_fields[$name]['max_length'])) {
                 $options_name = my_substr($options_name,0, $this->form_fields[$name]['max_length']);
             }
             $ret .= "\n<option value=\"".htmlReady($options_value)."\" " . (($selected) ? " selected " : "");
@@ -387,15 +388,15 @@ class StudipForm {
     }
 
     function getFormButton($name, $attributes = []){
-        if (is_array($this->form_buttons[$name]['attributes'])) {
+        if (!empty($this->form_buttons[$name]['attributes']) && is_array($this->form_buttons[$name]['attributes'])) {
             $attributes = array_merge((array)$attributes, (array)$this->form_buttons[$name]['attributes']);
         }
-        if (!$this->form_buttons[$name]['is_picture']) {
+        if (empty($this->form_buttons[$name]['is_picture'])) {
             if (isset($this->form_buttons[$name]['info']) && !isset($attributes['title'])) {
                 $attributes['title'] = $this->form_buttons[$name]['info'];
             }
             $caption = $this->form_buttons[$name]['caption'] ? $this->form_buttons[$name]['caption'] : $this->form_buttons[$name]['type'];
-            if (in_array($this->form_buttons[$name]['type'], words('cancel accept'))) {
+            if (!empty($this->form_buttons[$name]['type']) && in_array($this->form_buttons[$name]['type'], ['cancel', 'accept'])) {
                 $create = 'create' . $this->form_buttons[$name]['type'];
             } else {
                 $create = 'create';
@@ -457,7 +458,7 @@ class StudipForm {
         if (isset($this->form_values[$name])){
             $value = $this->form_values[$name];
         } else {
-            $value = $this->form_fields[$name]['default_value'];
+            $value = $this->form_fields[$name]['default_value'] ?? '';
         }
         return $value;
     }
@@ -465,7 +466,7 @@ class StudipForm {
     function getFormFieldsByName($only_editable = false){
         $ret = [];
         foreach ($this->form_fields as $name => $detail){
-            if( !($only_editable && ($detail['type'] == 'noform' || $detail['disabled'])) ){
+            if( !($only_editable && ($detail['type'] == 'noform' || !empty($detail['disabled']))) ){
                 $ret[] = $name;
             }
         }
diff --git a/lib/classes/StudipSemRangeTreeViewSimple.class.php b/lib/classes/StudipSemRangeTreeViewSimple.class.php
index 41744bd5ed2..eecdd70cd1f 100644
--- a/lib/classes/StudipSemRangeTreeViewSimple.class.php
+++ b/lib/classes/StudipSemRangeTreeViewSimple.class.php
@@ -61,7 +61,7 @@ class StudipSemRangeTreeViewSimple {
         }
         $args['visible_only'] = $visible_only;
         $this->tree = TreeAbstract::GetInstance("StudipRangeTree",$args);
-        if (!$this->tree->tree_data[$this->start_item_id]){
+        if (empty($this->tree->tree_data[$this->start_item_id])) {
             $this->start_item_id = "root";
         }
     }
@@ -156,6 +156,7 @@ class StudipSemRangeTreeViewSimple {
         if ($item_id == "root"){
             $ret = ($this->root_content) ? $this->root_content : _("Keine weitere Info vorhanden");
         } else {
+            $info = '';
             $range_object = RangeTreeObject::GetInstance($item_id);
             if (is_array($range_object->item_data_mapping)){
                 foreach ($range_object->item_data_mapping as $key => $value){
@@ -165,7 +166,7 @@ class StudipSemRangeTreeViewSimple {
                     }
                 }
             }
-            $ret = ($info) ? $info :  _("Keine weitere Info vorhanden");
+            $ret = $info ?:  _("Keine weitere Info vorhanden");
         }
         return $ret;
     }
@@ -211,6 +212,7 @@ class StudipSemRangeTreeViewSimple {
     public function getSemPath($start_id = null)
     {
         $parents = $this->tree->getParents($this->start_item_id);
+        $ret = '';
         if ($parents) {
             $add_item = false;
             $start_id = $start_id === null ? 'root' : $start_id;
diff --git a/lib/classes/StudipSemSearch.class.php b/lib/classes/StudipSemSearch.class.php
index e12c443140e..8932dd12500 100644
--- a/lib/classes/StudipSemSearch.class.php
+++ b/lib/classes/StudipSemSearch.class.php
@@ -158,7 +158,9 @@ class StudipSemSearch {
         return $this->form->getFormStart($action, $attributes);
     }
 
-    function getFormEnd(){
+    function getFormEnd()
+    {
+        $ret = '';
         if ($this->search_sem_class != 'all'){
             $ret = $this->form->getHiddenField('category',$this->search_sem_class);
         }
diff --git a/lib/classes/StudipSemSearchHelper.class.php b/lib/classes/StudipSemSearchHelper.class.php
index 3875bc2e309..e87da1bb95b 100644
--- a/lib/classes/StudipSemSearchHelper.class.php
+++ b/lib/classes/StudipSemSearchHelper.class.php
@@ -92,10 +92,11 @@ class StudipSemSearchHelper {
         }
 
         $sem_types = [];
-        if (isset($this->params['category']) && $this->params['category'] !== 'all'){
-            foreach ($GLOBALS['SEM_TYPE'] as $type_key => $type_value){
-                if ($type_value['class'] == $this->params['category'])
+        if (isset($this->params['category']) && $this->params['category'] !== 'all') {
+            foreach ($GLOBALS['SEM_TYPE'] as $type_key => $type_value) {
+                if ($type_value['class'] == $this->params['category']) {
                     $sem_types[] = $type_key;
+                }
             }
         }
 
@@ -176,8 +177,10 @@ class StudipSemSearchHelper {
 
             $toFilter = explode(" ", $this->params['title']);
             $search_for = "(Name LIKE '%" . implode("%' AND Name LIKE '%", $toFilter) . "%')";
-            $view->params[0] = $this->params['title'] ? $search_for . " " : " ";
-
+            if (!array_key_exists(0, $view->params)) {
+                $view->params[0] = '';
+            }
+            $view->params[0] .= ($this->params['title']) ? $search_for . " " : " ";
             $view->params[0] .= ($this->params['title'] && $this->params['sub_title']) ? $combination : " ";
             $view->params[0] .= ($this->params['sub_title']) ? " Untertitel LIKE '%" . $this->trim($this->params['sub_title']) . "%' " : " ";
             $view->params[0] .= (($this->params['title'] || $this->params['sub_title']) && $this->params['comment']) ? $combination : " ";
diff --git a/lib/classes/StudipSemTree.class.php b/lib/classes/StudipSemTree.class.php
index 33377975490..82fd37ca588 100644
--- a/lib/classes/StudipSemTree.class.php
+++ b/lib/classes/StudipSemTree.class.php
@@ -38,7 +38,7 @@ class StudipSemTree extends TreeAbstract
         if (isset($args['sem_number']) ){
             $this->sem_number = array_map('intval', $args['sem_number']);
         }
-        if ($args['sem_status']){
+        if (!empty($args['sem_status'])) {
             $this->sem_status = array_map('intval', $args['sem_status']);
         } else {
             foreach ($GLOBALS['SEM_CLASS'] as $key => $value){
@@ -115,8 +115,9 @@ class StudipSemTree extends TreeAbstract
 
     public function getSemIds($item_id,$ids_from_kids = false)
     {
-        if (!$this->tree_data[$item_id])
+        if (empty($this->tree_data[$item_id])) {
             return false;
+        }
         $this->view->params[0] = $this->sem_status;
         $this->view->params[1] = $this->visible_only ? "visible=1" : "1";
         if ($ids_from_kids && $item_id != 'root'){
diff --git a/lib/classes/StudipSemTreeViewSimple.class.php b/lib/classes/StudipSemTreeViewSimple.class.php
index a78e2178977..560f7ccb1cb 100644
--- a/lib/classes/StudipSemTreeViewSimple.class.php
+++ b/lib/classes/StudipSemTreeViewSimple.class.php
@@ -60,7 +60,7 @@ class StudipSemTreeViewSimple
         $args['visible_only'] = $visible_only;
         $this->tree = TreeAbstract::GetInstance("StudipSemTree",$args);
         $this->tree->enable_lonely_sem = false;
-        if (!$this->tree->tree_data[$this->start_item_id]){
+        if (empty($this->tree->tree_data[$this->start_item_id])) {
             $this->start_item_id = "root";
         }
     }
@@ -145,8 +145,9 @@ class StudipSemTreeViewSimple
                 <td class="table_row_even kids-tree-row" align="left" valign="top">
                     <ul class="semtree">';
         for ($i = 0; $i < $num_kids; ++$i){
+            $num_entries = 0;
             if ($this->start_item_id != 'root') {
-            $num_entries = $this->tree->getNumEntries($kids[$i],true);
+                $num_entries = $this->tree->getNumEntries($kids[$i],true);
                 $num_all_entries += $num_entries;
             }
             $kids_table .= "<li><a " . ($num_entries ? tooltip(sprintf(_("%s Einträge in allen Unterebenen vorhanden"), $num_entries), false) : '') . " href=\"" .URLHelper::getLink($this->getSelf("start_item_id={$kids[$i]}", false)) . "\">";
@@ -212,6 +213,7 @@ class StudipSemTreeViewSimple
 
     public function getSemPath($start_id = null)
     {
+        $ret = '';
         $parents = $this->tree->getParents($this->start_item_id);
         if ($parents) {
             $add_item = false;
diff --git a/lib/classes/TreeAbstract.class.php b/lib/classes/TreeAbstract.class.php
index b06cbcd49c8..dc9682073d6 100644
--- a/lib/classes/TreeAbstract.class.php
+++ b/lib/classes/TreeAbstract.class.php
@@ -112,7 +112,7 @@ class TreeAbstract {
         } else {
             $class_hash = $class_name;
         }
-        if (!is_object($tree_instance[$class_hash]) || $invalidate_cache){
+        if (empty($tree_instance[$class_hash]) || $invalidate_cache){
             $tree_instance[$class_hash] = new $class_name($args);
         }
 
@@ -162,7 +162,10 @@ class TreeAbstract {
         $this->tree_data[$item_id]["priority"] = $priority;
         $this->tree_data[$item_id]["name"] = $name;
         $this->tree_childs[$parent_id][] = $item_id;
-        ++$this->tree_num_childs[$parent_id];
+        if (empty($this->tree_num_childs[$parent_id])) {
+            $this->tree_num_childs[$parent_id] = 0;
+        }
+        $this->tree_num_childs[$parent_id]++;
         return;
     }
 
@@ -213,7 +216,7 @@ class TreeAbstract {
     public function getNumKids($item_id)
     {
         if(!isset($this->tree_num_childs[$item_id])){
-            $this->tree_num_childs[$item_id] = (is_array($this->tree_childs[$item_id])) ? count($this->tree_childs[$item_id]) : 0;
+            $this->tree_num_childs[$item_id] = (!empty($this->tree_childs[$item_id]) && is_array($this->tree_childs[$item_id])) ? count($this->tree_childs[$item_id]) : 0;
         }
         return $this->tree_num_childs[$item_id];
     }
diff --git a/lib/classes/globalsearch/GlobalSearchCourses.php b/lib/classes/globalsearch/GlobalSearchCourses.php
index a490b2e2f09..5914cfc6d14 100644
--- a/lib/classes/globalsearch/GlobalSearchCourses.php
+++ b/lib/classes/globalsearch/GlobalSearchCourses.php
@@ -58,6 +58,13 @@ class GlobalSearchCourses extends GlobalSearchModule implements GlobalSearchFull
                                   AND `lang` = " . DBManager::get()->quote($_SESSION['_language']);
         }
 
+        $visibility = '';
+        $seminaruser = '';
+        $semester_join = '';
+        $institute_condition = '';
+        $seminar_type_condition = '';
+        $semester_condition = '';
+
         // visibility
         if (!$GLOBALS['perm']->have_perm('admin')) {
             $visibility = "courses.`visible` = 1 AND ";
@@ -70,7 +77,7 @@ class GlobalSearchCourses extends GlobalSearchModule implements GlobalSearchFull
 
         // generate SQL for the given sidebar filter (semester, institute, seminar_type)
         if ($filter['category'] === self::class || $filter['category'] === 'show_all_categories') {
-            if ($filter['semester']) {
+            if (!empty($filter['semester'])) {
                 if ($filter['semester'] === 'future') {
                     $semester = Semester::findCurrent();
                     $next_semester = Semester::findNext();
@@ -85,11 +92,11 @@ class GlobalSearchCourses extends GlobalSearchModule implements GlobalSearchFull
                         semester_courses.semester_id IS NULL OR semester_courses.semester_id IN (" . join(',', array_map([DBManager::get(), 'quote'], $semester_ids)) . ")
                     ) ";
             }
-            if ($filter['institute']) {
+            if (!empty($filter['institute'])) {
                 $institutes = self::getInstituteIdsForSQL($filter['institute']);
                 $institute_condition = " AND `courses`.`Institut_id` IN (" . DBManager::get()->quote($institutes) . ") ";
             }
-            if ($filter['seminar_type']) {
+            if (!empty($filter['seminar_type'])) {
                 $seminar_types = self::getSeminarTypesForSQL($filter['seminar_type']);
                 $seminar_type_condition = " AND `courses`.`status` IN (" . DBManager::get()->quote($seminar_types) . ") ";
             }
@@ -288,7 +295,7 @@ class GlobalSearchCourses extends GlobalSearchModule implements GlobalSearchFull
 	    $stmt->execute([$seminar_id]);
 	    $result = $stmt->fetch();
 
-        if ($result['types']) {
+        if (!empty($result['types'])) {
             if ($result['type_locked']) {
                 return 2;
             }
diff --git a/lib/classes/globalsearch/GlobalSearchForum.php b/lib/classes/globalsearch/GlobalSearchForum.php
index 8c152c888f2..999757ac131 100644
--- a/lib/classes/globalsearch/GlobalSearchForum.php
+++ b/lib/classes/globalsearch/GlobalSearchForum.php
@@ -45,6 +45,7 @@ class GlobalSearchForum extends GlobalSearchModule implements GlobalSearchFullte
         $query = DBManager::get()->quote("%$search%");
 
         // visibility
+        $seminaruser = '';
         if (!$GLOBALS['perm']->have_perm('admin')) {
             $seminaruser = " AND EXISTS (
                 SELECT 1 FROM `seminar_user`
@@ -54,8 +55,9 @@ class GlobalSearchForum extends GlobalSearchModule implements GlobalSearchFullte
         }
 
         // generate SQL condition for the semester filter in the sidebar
+        $semester_condition = '';
         if ($filter['category'] == self::class || $filter['category'] == "show_all_categories") {
-            if ($filter['semester'] != "") {
+            if (!empty($filter['semester'])) {
                 if ($filter['semester'] === 'future') {
                     $semester = Semester::findCurrent();
                     $next_semester = Semester::findNext();
diff --git a/lib/classes/globalsearch/GlobalSearchModule.php b/lib/classes/globalsearch/GlobalSearchModule.php
index 49d5e74b899..7e9f251d2d7 100644
--- a/lib/classes/globalsearch/GlobalSearchModule.php
+++ b/lib/classes/globalsearch/GlobalSearchModule.php
@@ -127,7 +127,7 @@ abstract class GlobalSearchModule
 
         // Replace camelcase
         $i = 1;
-        $replacement = "${$i}";
+        $replacement = '$1';
         foreach (preg_split('//u', mb_strtoupper($query), -1, PREG_SPLIT_NO_EMPTY) as $letter) {
             $quoted = preg_quote($letter, '/');
             $queryletter[] = "({$quoted})";
diff --git a/lib/classes/globalsearch/GlobalSearchMyCourses.php b/lib/classes/globalsearch/GlobalSearchMyCourses.php
index a058b0b4c30..10d7be49d0e 100644
--- a/lib/classes/globalsearch/GlobalSearchMyCourses.php
+++ b/lib/classes/globalsearch/GlobalSearchMyCourses.php
@@ -46,8 +46,12 @@ class GlobalSearchMyCourses extends GlobalSearchModule
         }
 
         // generate SQL for the given sidebar filter (semester, institute, seminar_type)
+        $semester_join = '';
+        $institute_condition = '';
+        $seminar_type_condition = '';
+        $semester_condition = '';
         if ($filter['category'] === self::class || $filter['category'] == 'show_all_categories') {
-            if ($filter['semester']) {
+            if (!empty($filter['semester'])) {
                 if ($filter['semester'] === 'future') {
                     $semester = Semester::findCurrent();
                     $next_semester = Semester::findNext();
@@ -62,11 +66,11 @@ class GlobalSearchMyCourses extends GlobalSearchModule
                         semester_courses.semester_id IS NULL OR semester_courses.semester_id IN (" . join(',', array_map([DBManager::get(), 'quote'], $semester_ids)) . ")
                     ) ";
             }
-            if ($filter['institute']) {
+            if (!empty($filter['institute'])) {
                 $institutes = self::getInstituteIdsForSQL($filter['institute']);
                 $institute_condition = " AND `courses`.`Institut_id` IN (" .DBManager::get()->quote($institutes). ") ";
             }
-            if ($filter['seminar_type']) {
+            if (!empty($filter['seminar_type'])) {
                 $seminar_types = self::getSeminarTypesForSQL($filter['seminar_type']);
                 $seminar_type_condition = " AND `courses`.`status` IN (" .DBManager::get()->quote($seminar_types). ") ";
             }
diff --git a/lib/classes/globalsearch/GlobalSearchUsers.php b/lib/classes/globalsearch/GlobalSearchUsers.php
index b9daa4924ab..548c6ac90c4 100644
--- a/lib/classes/globalsearch/GlobalSearchUsers.php
+++ b/lib/classes/globalsearch/GlobalSearchUsers.php
@@ -37,6 +37,7 @@ class GlobalSearchUsers extends GlobalSearchModule implements GlobalSearchFullte
         }
 
         // if you're no admin respect visibilty
+        $visQuery = '';
         if (!$GLOBALS['perm']->have_perm('admin')) {
             $visQuery = get_vis_query('user', 'search') . " AND ";
         }
diff --git a/lib/classes/searchtypes/SearchType.class.php b/lib/classes/searchtypes/SearchType.class.php
index e0914dc4417..d46d57e6af3 100644
--- a/lib/classes/searchtypes/SearchType.class.php
+++ b/lib/classes/searchtypes/SearchType.class.php
@@ -23,6 +23,8 @@
  */
 abstract class SearchType
 {
+    public $extendedLayout = false;
+
 
     /**
      * title of the search like "search for courses" or just "courses"
diff --git a/lib/classes/sidebar/ClipboardWidget.class.php b/lib/classes/sidebar/ClipboardWidget.class.php
index 90de0c40d24..abc0d6ca16a 100644
--- a/lib/classes/sidebar/ClipboardWidget.class.php
+++ b/lib/classes/sidebar/ClipboardWidget.class.php
@@ -69,7 +69,8 @@ class ClipboardWidget extends SidebarWidget
         $this->clipboard_widget_id = md5(uniqid('clipboard_widget_id'));
 
         $this->updateSessionVariables();
-        $this->current_clipboard_id = $_SESSION['selected_clipboard_id'];
+        $this->current_clipboard_id = $_SESSION['selected_clipboard_id'] ?? '';
+
         $this->setId("ClipboardWidget_{$this->clipboard_widget_id}");
         $this->setAdditionalAttribute('data-widget_id', $this->clipboard_widget_id);
         $this->addLayoutCSSClass('clipboard-widget');
diff --git a/lib/classes/sidebar/ResourceTreeWidget.class.php b/lib/classes/sidebar/ResourceTreeWidget.class.php
index 75befd4e616..34907ce5e61 100644
--- a/lib/classes/sidebar/ResourceTreeWidget.class.php
+++ b/lib/classes/sidebar/ResourceTreeWidget.class.php
@@ -115,6 +115,7 @@ class ResourceTreeWidget extends SidebarWidget
         $variables['resource_path'] = $resource_path;
         $variables['max_open_depth'] = 0;
         $variables['layout_css_classes'] = $this->layout_css_classes;
+        $variables['hide'] = false;
 
         return parent::render($variables);
     }
diff --git a/lib/classes/sidebar/RoomSearchWidget.class.php b/lib/classes/sidebar/RoomSearchWidget.class.php
index da2238e5fdd..af7a8192fcf 100644
--- a/lib/classes/sidebar/RoomSearchWidget.class.php
+++ b/lib/classes/sidebar/RoomSearchWidget.class.php
@@ -301,7 +301,7 @@ class RoomSearchWidget extends SidebarWidget
 
     protected function restoreSearchFromSession()
     {
-        if (is_array($_SESSION['room_search_criteria']['room_search'])) {
+        if (!empty($_SESSION['room_search_criteria']['room_search']) && is_array($_SESSION['room_search_criteria']['room_search'])) {
             $this->selected_criteria =
                 $_SESSION['room_search_criteria']['room_search'];
         } else {
diff --git a/lib/models/Modulteil.php b/lib/models/Modulteil.php
index deffb5e4dba..14a34baa3c3 100644
--- a/lib/models/Modulteil.php
+++ b/lib/models/Modulteil.php
@@ -141,9 +141,7 @@ class Modulteil extends ModuleManagementModelTreeItem
         } else if ($this->nummer) {
             $name .= $this->nummer . ': ';
         }
-        $name .= $GLOBALS['MVV_MODULTEIL']['LERNLEHRFORM']['values'][$this->lernlehrform]
-                ? $GLOBALS['MVV_MODULTEIL']['LERNLEHRFORM']['values'][$this->lernlehrform]['name']
-                : '';
+        $name .= $GLOBALS['MVV_MODULTEIL']['LERNLEHRFORM']['values'][$this->lernlehrform]['name'] ?? '';
         $deskriptor = $this->getDeskriptor(self::getLanguage());
         if (strlen(trim($deskriptor->bezeichnung))) {
             $name .= $name == '' ? $deskriptor->bezeichnung
diff --git a/lib/models/SimpleCollection.class.php b/lib/models/SimpleCollection.class.php
index 4d9808703cc..588de1b871d 100644
--- a/lib/models/SimpleCollection.class.php
+++ b/lib/models/SimpleCollection.class.php
@@ -684,7 +684,9 @@ class SimpleCollection extends StudipArrayObject
 
         $func = function ($d1, $d2) use ($sorter, $sort_func, $sort_locale) {
             do {
-                list($field, $dir) = current($sorter);
+                $field = current($sorter);
+                $dir = $field[1] ?? '';
+                $field = $field[0] ?? '';
                 if (!$sort_locale) {
                     $value1 = $d1[$field];
                     $value2 = $d2[$field];
diff --git a/lib/models/resources/Location.class.php b/lib/models/resources/Location.class.php
index f380859e0da..c5431533963 100644
--- a/lib/models/resources/Location.class.php
+++ b/lib/models/resources/Location.class.php
@@ -23,10 +23,10 @@ class Location extends Resource
     protected static $required_properties = [
         'geo_coordinates'
     ];
-    
+
     protected static function configure($config = [])
     {
-        if (!is_array($config['additional_fields'])) {
+        if (!isset($config['additional_fields'])) {
             $config['additional_fields'] = [];
         }
         foreach (self::$required_properties as $property) {
@@ -35,18 +35,18 @@ class Location extends Resource
                 'set' => 'setProperty'
             ];
         }
-        
+
         $config['additional_fields']['buildings']['get'] = 'findBuildings';
-        
+
         $config['additional_fields']['director'] = [
             'get' => 'getPropertyRelatedObject',
             'set' => 'setPropertyRelatedObject'
         ];
-        
+
         $config['registered_callbacks']['before_store'][] = 'cbValidate';
         parent::configure($config);
     }
-    
+
     public static function getTranslatedClassName($item_count = 1)
     {
         return ngettext(
@@ -55,7 +55,7 @@ class Location extends Resource
             $item_count
         );
     }
-    
+
     /**
      * Returns all locations which are stored in the database.
      *
@@ -70,7 +70,7 @@ class Location extends Resource
             ORDER BY sort_position DESC, name ASC, mkdate ASC"
         );
     }
-    
+
     /**
      * Returns the part of the URL for getLink and getURL which will be
      * placed inside the calls to URLHelper::getLink and URLHelper::getURL
@@ -83,7 +83,7 @@ class Location extends Resource
                 _('Zuer Erstellung der URL fehlt eine Standort-ID!')
             );
         }
-        
+
         switch ($action) {
             case 'show':
                 return 'dispatch.php/resources/location/index/' . $id;
@@ -99,7 +99,7 @@ class Location extends Resource
                 return parent::buildPathForAction($action, $id);
         }
     }
-    
+
     /**
      * Returns the appropriate link for the location action that shall be
      * executed on a location.
@@ -124,8 +124,8 @@ class Location extends Resource
             $link_parameters
         );
     }
-    
-    
+
+
     /**
      * Returns the appropriate URL for the location action that shall be
      * executed on a location.
@@ -150,12 +150,12 @@ class Location extends Resource
             $url_parameters
         );
     }
-    
+
     public function getRequiredPropertyNames()
     {
         return self::$required_properties;
     }
-    
+
     /**
      * @see StudipItem::__toString
      */
@@ -163,7 +163,7 @@ class Location extends Resource
     {
         return $this->getFullName();
     }
-    
+
     public function cbValidate()
     {
         if ($this->parent_id) {
@@ -175,7 +175,7 @@ class Location extends Resource
                 )
             );
         }
-        
+
         if (!is_a($this->category->class_name, get_class($this), true)) {
             //Only resources with the Location category can be handled
             //with this class!
@@ -187,7 +187,7 @@ class Location extends Resource
             );
         }
     }
-    
+
     /**
      * Returns the full (localised) name of the location.
      *
@@ -200,30 +200,30 @@ class Location extends Resource
             $this->name
         );
     }
-    
+
     public function getDefaultPictureUrl()
     {
         return $this->getIcon()->asImagePath();
     }
-    
+
     public function getIcon($role = Icon::ROLE_INFO)
     {
         return Icon::create('place', $role);
     }
-    
+
     public function checkHierarchy()
     {
         //We must check if this location has locations as children
         //or rooms, buildings or locations as parents.
         //In any of those cases the hierarchy is invalid!
-        
+
         $children = $this->findChildrenByClassName('Location');
         if (count($children) > 0) {
             //At least one child anywhere below this location
             //resource is a location, too.
             return false;
         }
-        
+
         $parents = ResourceManager::getHierarchy($this);
         //We do not need to check this element:
         array_shift($parents);
@@ -235,12 +235,12 @@ class Location extends Resource
                 return false;
             }
         }
-        
+
         //If code execution reaches this point then
         //the hierarchy around this location is valid.
         return true;
     }
-    
+
     /**
      * Returns the link for an action for this building.
      * This is the non-static variant of Building::getLinkForAction.
@@ -260,7 +260,7 @@ class Location extends Resource
             $link_parameters
         );
     }
-    
+
     /**
      * Returns the URL for an action for this location.
      * This is the non-static variant of Location::getURLForAction.
@@ -279,9 +279,9 @@ class Location extends Resource
             $url_parameters
         );
     }
-    
+
     // Relation methods:
-    
+
     /**
      * Retrieves the buildings which are associated to this location
      * by looking up the child resources of this location.
@@ -292,14 +292,14 @@ class Location extends Resource
     public function findBuildings()
     {
         $buildings = parent::findChildrenByClassName('Building');
-        
+
         $result = [];
         foreach ($buildings as $building) {
             $result[] = Building::toObject($building);
         }
         return $result;
     }
-    
+
     /**
      * Adds a child resource to this location. The child resource
      * must not be a resource of the Location class.
@@ -320,7 +320,7 @@ class Location extends Resource
         }
         return parent::addChild($resource);
     }
-    
+
     public function createSimpleBooking(
         User $user,
         DateTime $begin,
@@ -333,7 +333,7 @@ class Location extends Resource
     {
         return null;
     }
-    
+
     public function createBookingFromRequest(
         User $user,
         ResourceRequest $request,
@@ -347,7 +347,7 @@ class Location extends Resource
     {
         return null;
     }
-    
+
     public function createBooking(
         User $user,
         $range_id = null,
@@ -364,7 +364,7 @@ class Location extends Resource
     {
         return null;
     }
-    
+
     public function createSimpleRequest(
         User $user,
         DateTime $begin,
@@ -375,7 +375,7 @@ class Location extends Resource
     {
         return null;
     }
-    
+
     public function createRequest(
         User $user,
         $date_range_ids = null,
@@ -386,7 +386,7 @@ class Location extends Resource
     {
         return null;
     }
-    
+
     public function createLock(
         User $user,
         DateTime $begin,
@@ -396,7 +396,7 @@ class Location extends Resource
     {
         return null;
     }
-    
+
     public function isAssigned(
         DateTime $begin,
         DateTime $end,
@@ -405,7 +405,7 @@ class Location extends Resource
     {
         return false;
     }
-    
+
     public function isReserved(
         DateTime $begin,
         DateTime $end,
@@ -414,7 +414,7 @@ class Location extends Resource
     {
         return false;
     }
-    
+
     public function isLocked(
         DateTime $begin,
         DateTime $end,
@@ -423,7 +423,7 @@ class Location extends Resource
     {
         return true;
     }
-    
+
     public function isAvailable(
         DateTime $begin,
         DateTime $end,
diff --git a/lib/raumzeit/SingleDate.class.php b/lib/raumzeit/SingleDate.class.php
index 3cda04d027a..d5f1d00423e 100644
--- a/lib/raumzeit/SingleDate.class.php
+++ b/lib/raumzeit/SingleDate.class.php
@@ -391,8 +391,8 @@ class SingleDate
         $this->end_time = $daten['end_time'];
         $this->mkdate = $daten['mkdate'];
         $this->chdate = $daten ['chdate'];
-        $this->ex_termin = $daten['ex_termin'] ?? false;
-        $this->orig_ex = $daten['ex_termin'] ?? false;
+        $this->ex_termin = $daten['ex_termin'] ?? null;
+        $this->orig_ex = $daten['ex_termin'] ?? null;
         $this->range_id = $daten['range_id'];
         $this->author_id = $daten['autor_id'];
         $this->resource_id = $daten['resource_id'];
diff --git a/templates/sidebar/room-clipboard-item.php b/templates/sidebar/room-clipboard-item.php
index a433c9d4d05..da848f7acf1 100644
--- a/templates/sidebar/room-clipboard-item.php
+++ b/templates/sidebar/room-clipboard-item.php
@@ -29,10 +29,10 @@ if (!$item) {
 }
 ?>
 <tr class="<?= htmlReady($classes) ?>"
-    data-range_id="<?= htmlReady($item['range_id']) ?>">
+    data-range_id="<?= htmlReady($item['range_id'] ?? '') ?>">
     <td class="item-name"><?= htmlReady($item['name']) ?></td>
     <td class="actions">
-        <a href="<?= Room::getLinkForAction('show', ($item ? $item['range_id'] : 'RANGE_ID')) ?>" data-dialog>
+        <a href="<?= Room::getLinkForAction('show', (!empty($item) ? $item['range_id'] : 'RANGE_ID')) ?>" data-dialog>
             <?= Icon::create(
                     'info-circle',
                     Icon::ROLE_CLICKABLE,
@@ -41,7 +41,7 @@ if (!$item) {
                         'class' => 'text-bottom'
                     ])?>
         </a>
-        <a href="<?= Room::getLinkForAction('semester_plan', ($item ? $item['range_id'] : 'RANGE_ID')) ?>" target="_blank">
+        <a href="<?= Room::getLinkForAction('semester_plan', (!empty($item) ? $item['range_id'] : 'RANGE_ID')) ?>" target="_blank">
             <?= Icon::create(
                     'timetable',
                     Icon::ROLE_CLICKABLE,
diff --git a/templates/sidebar/room-search-widget.php b/templates/sidebar/room-search-widget.php
index f0b22c82f4f..ac679b490ae 100644
--- a/templates/sidebar/room-search-widget.php
+++ b/templates/sidebar/room-search-widget.php
@@ -8,7 +8,7 @@
             [
                 'criteria' => (
                 $selected_criteria['special__room_name']
-                    ?: $criteria['special__room_name']
+                    ?? $criteria['special__room_name']
                 ),
                 'removable' => false
             ]
@@ -30,7 +30,8 @@
             [
                 'criteria' => (
                 $selected_criteria['room_category_id']
-                    ?: $criteria['room_category_id']
+                    ?? $criteria['room_category_id']
+                    ?? []
                 ),
                 'removable' => false
             ]
@@ -40,18 +41,19 @@
             [
                 'criteria' => (
                     $selected_criteria['special__building_location']
-                    ?: $criteria['special__building_location']
+                    ?? $criteria['special__building_location']
+                    ?? []
                     ),
                 'removable' => false
             ]
         ) ?>
-        <? if ($selected_criteria['special__building_location_label'] || $criteria['special__building_location_label']): ?>
+        <? if (!empty($selected_criteria['special__building_location_label']) || !empty($criteria['special__building_location_label'])): ?>
             <?= $this->render_partial(
                 'sidebar/room-search-criteria.php',
                 [
                     'criteria' => (
                         $selected_criteria['special__building_location_label']
-                        ?: $criteria['special__building_location_label']
+                        ?? $criteria['special__building_location_label']
                         ),
                     'removable' => false
                 ]
@@ -60,16 +62,15 @@
         <?= $this->render_partial(
             'sidebar/room-search-criteria-seats.php',
             [
-                'criteria' =>
-                    $selected_criteria['special__seats']
-                    ?: $criteria['special__seats']
+                'criteria'  => $selected_criteria['special__seats'] ?? $criteria['special__seats'],
+                'removable' => false
             ]
         ) ?>
         <?= $this->render_partial(
             'sidebar/room-search-criteria-available-range.php',
             [
                 'criteria' => $selected_criteria['special__time_range']
-                          ?: $criteria['special__time_range']
+                          ?? $criteria['special__time_range']
             ]
         ) ?>
 
@@ -108,10 +109,13 @@
                         data-type="<?= htmlReady($c['type']) ?>"
                         data-range-search="<?= htmlReady($c['range_search']) ?>"
                         data-select_options="<?= htmlReady(
-                                             is_array($c['options'])
-                                             ? implode(';;', $c['options'])
-                                             : $c['options']
-                                             ) ?>"
+                            !empty($c['options'])
+                                ? (is_array($c['options'])
+                                  ? implode(';;', $c['options'])
+                                  : $c['options']
+                                )
+                                : ''
+                        ) ?>"
                         <?= in_array($c['name'], array_keys($selected_criteria))
                           ? 'class="invisible"'
                           : ''?>>
diff --git a/vendor/write_excel/OLEwriter.php b/vendor/write_excel/OLEwriter.php
index 17bdfd649db..b82f3aa6430 100644
--- a/vendor/write_excel/OLEwriter.php
+++ b/vendor/write_excel/OLEwriter.php
@@ -347,7 +347,7 @@ class OLEwriter
             for($i=0;$i<strlen($name);$i++)
             {
                 // Simulate a Unicode string
-                $rawname .= pack("H*",dechex(ord($name{$i}))).pack("C",0);
+                $rawname .= pack("H*",dechex(ord($name[$i]))).pack("C",0);
             }
             $length = strlen($name) * 2;
         }
@@ -411,4 +411,4 @@ class OLEwriter
         }
     }
 }
-?>
\ No newline at end of file
+?>
diff --git a/vendor/write_excel/Parser.php b/vendor/write_excel/Parser.php
index 1b7030e9275..1646f74bad3 100644
--- a/vendor/write_excel/Parser.php
+++ b/vendor/write_excel/Parser.php
@@ -642,7 +642,7 @@ class Parser
     $col    = 0;
     for($i=0; $i < strlen($col_ref); $i++)
     {
-        $col += (ord($col_ref{$i}) - ord('A') + 1) * pow(26, $expn);
+        $col += (ord($col_ref[$i]) - ord('A') + 1) * pow(26, $expn);
         $expn--;
     }
 
@@ -662,30 +662,30 @@ class Parser
     // eat up white spaces
     if($i < strlen($this->_formula))
         {
-        while($this->_formula{$i} == " ")
+        while($this->_formula[$i] == " ")
             {
             $i++;
             }
         if($i < strlen($this->_formula) - 1)
             {
-            $this->_lookahead = $this->_formula{$i+1};
+            $this->_lookahead = $this->_formula[$i+1];
             }
         $token = "";
         }
     while($i < strlen($this->_formula))
         {
-        $token .= $this->_formula{$i};
+        $token .= $this->_formula[$i];
         if($this->_match($token) != '')
             {
             if($i < strlen($this->_formula) - 1)
                 {
-                $this->_lookahead = $this->_formula{$i+1};
+                $this->_lookahead = $this->_formula[$i+1];
                 }
             $this->_current_char = $i + 1;
             $this->_current_token = $token;
             return(1);
             }
-        $this->_lookahead = $this->_formula{$i+2};
+        $this->_lookahead = $this->_formula[$i+2];
         $i++;
         }
     //die("Lexical error ".$this->_current_char);
@@ -765,7 +765,7 @@ class Parser
     {
     $this->_current_char = 0;
     $this->_formula      = $formula;
-    $this->_lookahead    = $formula{1};
+    $this->_lookahead    = $formula[1];
     $this->_advance();
     $this->_parse_tree   = $this->_expression();
     }
-- 
GitLab