diff --git a/app/controllers/admin/datafields.php b/app/controllers/admin/datafields.php
index d30179169413f211f0729224376a14d7e1e58682..bf390c9fcbc2e1c3dc8ceb899f82190402f46aaf 100644
--- a/app/controllers/admin/datafields.php
+++ b/app/controllers/admin/datafields.php
@@ -181,7 +181,7 @@ class Admin_DatafieldsController extends AuthenticatedController
 
         $type = $type ?: Request::get('datafield_typ');
 
-        $this->type_name  = $this->allclasses[$type];
+        $this->type_name  = $this->allclasses[$type] ?? '';
         $this->object_typ = $type;
         $this->institutes = Institute::getMyInstitutes();
         if (!$this->object_typ) {
diff --git a/app/controllers/admin/sem_classes.php b/app/controllers/admin/sem_classes.php
index 42516853c3a0782fbfbd5d8e582bc420149039d7..aef3e8487d42e27be619bb28edf2b96e262357ba 100644
--- a/app/controllers/admin/sem_classes.php
+++ b/app/controllers/admin/sem_classes.php
@@ -136,6 +136,8 @@ class Admin_SemClassesController extends AuthenticatedController
         }
         if (!count($sem_class->getSemTypes())) {
             $notice = "<br>"._("Beachten Sie, dass es noch keine Veranstaltungstypen gibt!");
+        } else {
+            $notice = '';
         }
         $output = [
             'html' => (string) MessageBox::success(_("Änderungen wurden gespeichert."." ".'<a href="'.URLHelper::getLink("dispatch.php/admin/sem_classes/overview").'">'._("Zurück zur Übersichtsseite.").'</a>').$notice)
diff --git a/app/controllers/calendar/schedule.php b/app/controllers/calendar/schedule.php
index 9b106bd40f4776c95d4fb94e11f59b16207a79a7..7787813d54c25067627a2bb6dcd9265833001616 100644
--- a/app/controllers/calendar/schedule.php
+++ b/app/controllers/calendar/schedule.php
@@ -91,7 +91,7 @@ class Calendar_ScheduleController extends AuthenticatedController
             UserConfig::get($GLOBALS['user']->id)->store('SCHEDULE_SETTINGS',
                 $schedule_settings);
         } else {
-            $this->current_semester = $schedule_settings['semester_id'] ?
+            $this->current_semester = !empty(schedule_settings['semester_id']) ?
                 Semester::find($schedule_settings['semester_id']) :
                 Semester::findCurrent();
         }
diff --git a/app/controllers/calendar/single.php b/app/controllers/calendar/single.php
index 2067e394d532c2fd541728efd42a55ba279d8c16..0d4fcac413cc5c0a1b095e02cd9e52a6292df700 100644
--- a/app/controllers/calendar/single.php
+++ b/app/controllers/calendar/single.php
@@ -502,6 +502,8 @@ class Calendar_SingleController extends Calendar_CalendarController
             Request::set('sem_select', $sem);
         }
         $this->group_field = 'sem_number';
+        $this->order_by = $order_by;
+        $this->config_sem_number = Config::get()->IMPORTANT_SEMNUMBER;
         // Needed parameters for selecting courses
         $params = [
             'group_field'         => $this->group_field,
@@ -512,7 +514,6 @@ class Calendar_SingleController extends Calendar_CalendarController
         ];
 
         $this->sem_courses  = MyRealmModel::getPreparedCourses($sem, $params);
-
         $semesters       = new SimpleCollection(Semester::getAll());
         $this->sem       = $sem;
         $this->semesters = $semesters->orderBy('beginn desc');
diff --git a/app/controllers/contents/courseware.php b/app/controllers/contents/courseware.php
index 860fdc64d067786d1d9b1c18cd0e294807db6325..a91569c7b8355c76e83cd9ab40833c1c8fd8b4c8 100644
--- a/app/controllers/contents/courseware.php
+++ b/app/controllers/contents/courseware.php
@@ -78,7 +78,7 @@ class Contents_CoursewareController extends AuthenticatedController
 
         $last = UserConfig::get($this->user_id)->getValue('COURSEWARE_LAST_ELEMENT');
 
-        if ($last[$this->user_id]) {
+        if (!empty($last[$this->user_id])) {
             $this->entry_element_id = $last['global'];
             $struct = \Courseware\StructuralElement::findOneBySQL(
                 "id = ? AND range_id = ? AND range_type = 'user'",
diff --git a/app/controllers/oer/mymaterial.php b/app/controllers/oer/mymaterial.php
index b1015fd6974e586bb719c23846f9d6553989ca57..93b0cd40269d91eaf6d4f0cbc1e0d21ac6f1d94d 100644
--- a/app/controllers/oer/mymaterial.php
+++ b/app/controllers/oer/mymaterial.php
@@ -39,7 +39,7 @@ class Oer_MymaterialController extends AuthenticatedController
             $material->setData(Request::getArray('data'));
             $material['host_id'] = null;
             $material['license_identifier'] = Request::get('license', 'CC-BY-SA-4.0');
-            if ($_FILES['file']['tmp_name']) {
+            if (!empty($_FILES['file']['tmp_name'])) {
                 $material['content_type'] = $_FILES['file']['type'];
                 if (in_array($material['content_type'], $content_types)) {
                     mkdir($tmp_folder);
@@ -51,7 +51,7 @@ class Oer_MymaterialController extends AuthenticatedController
                 }
                 $material['filename'] = $_FILES['file']['name'];
                 move_uploaded_file($_FILES['file']['tmp_name'], $material->getFilePath());
-            } elseif($_SESSION['NEW_OER']['tmp_name']) {
+            } elseif (!empty($_SESSION['NEW_OER']['tmp_name'])) {
                 $material['content_type'] = $_SESSION['NEW_OER']['content_type'] ?: get_mime_type($_SESSION['NEW_OER']['tmp_name']);
                 if (in_array($material['content_type'], $content_types)) {
                     mkdir($tmp_folder);
@@ -66,10 +66,10 @@ class Oer_MymaterialController extends AuthenticatedController
             }
 
 
-            if ($_FILES['image']['tmp_name']) {
+            if (!empty($_FILES['image']['tmp_name'])) {
                 $material['front_image_content_type'] = $_FILES['image']['type'];
                 move_uploaded_file($_FILES['image']['tmp_name'], $material->getFrontImageFilePath());
-            } elseif($_SESSION['NEW_OER']['image_tmp_name']) {
+            } elseif (!empty($_SESSION['NEW_OER']['image_tmp_name'])) {
                 $material['front_image_content_type'] = get_mime_type($_SESSION['NEW_OER']['image_tmp_name']);
                 copy($_SESSION['NEW_OER']['image_tmp_name'], $material->getFrontImageFilePath());
             }
diff --git a/app/controllers/terms.php b/app/controllers/terms.php
index bf98df0a11e1f32ca35eb7b669a63afb8e5e0e4a..ef59395046f64a80b352a3b6052715983d64d063 100644
--- a/app/controllers/terms.php
+++ b/app/controllers/terms.php
@@ -25,7 +25,7 @@ class TermsController extends AuthenticatedController
         $this->redirect_token = Request::get('redirect_token');
 
         $this->compulsory = Config::get()->TERMS_CONFIG['compulsory'];
-
+        $this->denial_message = '';
         if (Request::isPost()) {
             CSRFProtection::verifyUnsafeRequest();
             if (Request::submitted('accept')) {
diff --git a/app/views/calendar/contentbox/_termin.php b/app/views/calendar/contentbox/_termin.php
index 188ec3e31f5a05edf652a79f892bc95d4339db7f..3c3fcffc942cfc45c7ca25b7c2f53009be414e2c 100644
--- a/app/views/calendar/contentbox/_termin.php
+++ b/app/views/calendar/contentbox/_termin.php
@@ -18,7 +18,7 @@
         </nav>
     </header>
     <div>
-        <? $themen = $termin['topics'] ? : [] ?>
+        <? $themen = $termin['topics'] ?? [] ?>
         <? if ($termin['description'] || count($themen)) : ?>
         <p><?= formatReady($termin['description']) ?></p>
         <? if (count($themen)) : ?>
diff --git a/app/views/calendar/schedule/index.php b/app/views/calendar/schedule/index.php
index 45a4c328b66d813b02f66fa11c6b68babd067e0d..fe022a2317765a8f19cd109eb701b755c29ce609 100644
--- a/app/views/calendar/schedule/index.php
+++ b/app/views/calendar/schedule/index.php
@@ -1,6 +1,6 @@
 <?php
 # Lifter010: TODO
-$zoom = $my_schedule_settings['zoom'];
+$zoom = $my_schedule_settings['zoom'] ?? 0;
 
 $sidebar = Sidebar::get();
 
diff --git a/app/views/calendar/single/year.php b/app/views/calendar/single/year.php
index 923b08556c303496ed5b73171f8199deebd3a141..7f81fa79a96d1ee5d7a014a2e7492bc6dca36baf 100644
--- a/app/views/calendar/single/year.php
+++ b/app/views/calendar/single/year.php
@@ -46,7 +46,10 @@
             </thead>
 
             <tbody>
-                <? $now = date('Ymd'); ?>
+                <?
+                $now = date('Ymd');
+                $count = 0;
+                ?>
                 <? for ($i = 1; $i < 32; $i++) : ?>
                     <tr>
                         <? for ($month = 1; $month < 13; $month++) : ?>
diff --git a/app/views/course/wizard/steps/basicdata/index_studygroup.php b/app/views/course/wizard/steps/basicdata/index_studygroup.php
index a1e1e74b7f653c1fe793a439e983b38f532ba77d..23b87b42d8b2308ad2ba1a8c8a0925bcb618117f 100644
--- a/app/views/course/wizard/steps/basicdata/index_studygroup.php
+++ b/app/views/course/wizard/steps/basicdata/index_studygroup.php
@@ -4,7 +4,7 @@
 
 <label class="col-3">
     <span class="required"><?= _('Name') ?></span>
-    <input type="text" name="name" id="wizard-name" maxlength="254" value="<?= $values['name'] ?>" required/>
+    <input type="text" name="name" id="wizard-name" maxlength="254" value="<?= htmlReady($values['name'] ?? '') ?>" required/>
 </label>
 
 <? if(count($types) > 1) : ?>
@@ -31,7 +31,7 @@
 <label class="col-3">
     <?= _('Beschreibung') ?>
     <textarea name="description" id="wizard-description"
-              rows="4"><?= htmlReady($values['description'])?></textarea>
+              rows="4"><?= htmlReady($values['description'] ?? '') ?></textarea>
 </label>
 
 
diff --git a/app/views/course/wizard/steps/studyareas/index.php b/app/views/course/wizard/steps/studyareas/index.php
index 1b35237bd93b46abe1050155c9e11953db104cc9..e8f811ed6785483d7681d90891bdcdae4a8d0d1d 100644
--- a/app/views/course/wizard/steps/studyareas/index.php
+++ b/app/views/course/wizard/steps/studyareas/index.php
@@ -19,13 +19,13 @@
             </ul>
         </li>
     </ul>
-    <? if (!$stepnumber && !$values['locked']) : ?>
+    <? if (!$stepnumber && !empty($values['locked'])) : ?>
         <div data-dialog-button class="hidden-no-js">
             <?= Studip\Button::createAccept(_('Speichern'), 'save') ?>
         </div>
     <? endif ?>
 </div>
-<? if (!$values['locked']) : ?>
+<? if (!empty($values['locked'])) : ?>
     <div id="studyareas" data-ajax-url="<?= $ajax_url ?>"
         data-forward-url="<?= $no_js_url ?>" data-no-search-result="<?=_('Es wurde kein Suchergebnis gefunden.') ?>">
         <h2><?= _('Alle Studienbereiche') ?></h2>
diff --git a/app/views/my_studygroups/_course.php b/app/views/my_studygroups/_course.php
index 52e3b327992d4fe41d46e84588f6ace778a0afb7..b3f6b6b44f47681398bf9d9d3393e3a1261c9b77 100644
--- a/app/views/my_studygroups/_course.php
+++ b/app/views/my_studygroups/_course.php
@@ -56,7 +56,7 @@
                     </a>
                 <? endif ?>
 
-            <? elseif ($group["binding"]) : ?>
+            <? elseif (!empty($group['binding'])) : ?>
                 <a href="<?= URLHelper::getLink('', ['auswahl' => $group['seminar_id'], 'cmd' => 'no_kill']) ?>">
                     <?= Icon::create('door-leave', 'inactive', ['title' => _("Die Teilnahme ist bindend. Bitte wenden Sie sich an die Lehrenden.")])->asImg(20) ?>
                 </a>
diff --git a/app/views/oer/market/index.php b/app/views/oer/market/index.php
index 947eca39c77065d4740261a56b4fe6d33d2e21a8..09dfa43a346d3daae8636d6af5ce8e0d7ff2dee2 100644
--- a/app/views/oer/market/index.php
+++ b/app/views/oer/market/index.php
@@ -1,6 +1,6 @@
 <?
+$tags = [];
 if ($best_nine_tags && count($best_nine_tags) > 0) {
-    $tags = [];
     foreach ($best_nine_tags as $tag) {
         $tags[] = [
             'tag_hash' => $tag['tag_hash'],
@@ -8,8 +8,8 @@ if ($best_nine_tags && count($best_nine_tags) > 0) {
         ];
     }
 }
-if ($materialien !== null) {
-    $material_data = [];
+$material_data = [];
+if (!empty($materialien)) {
     foreach ($materialien as $material) {
         $data = $material->toRawArray();
 
diff --git a/app/views/oer/mymaterial/edit.php b/app/views/oer/mymaterial/edit.php
index e9944f093e7a3e400243b355b5981bcf39b989d9..bfd7aae7e54a87fe3f9d7a8bb1765ac599679e7d 100644
--- a/app/views/oer/mymaterial/edit.php
+++ b/app/views/oer/mymaterial/edit.php
@@ -15,7 +15,7 @@
                        name="data[name]"
                        class="oername"
                        required
-                       value="<?= htmlReady($material['name'] ?: $template['name']) ?>"
+                       value="<?= htmlReady($material['name'] ?: $template['name'] ?? '') ?>"
                        @keyup="editName"
                        maxlength="64">
             </label>
@@ -44,8 +44,8 @@
 
                 <div>
                     <label class="file-upload logo_file"
-                           data-oldurl="<?= htmlReady($_SESSION['NEW_OER']['image_tmp_name'] ? URLHelper::getURL("dispatch.php/oer/mymaterial/show_tmp_image") : $material->getLogoURL()) ?>"
-                           data-customlogo="<?= $_SESSION['NEW_OER']['image_tmp_name'] || $material['front_image_content_type'] ? 1 : 0 ?>">
+                           data-oldurl="<?= htmlReady(!empty($_SESSION['NEW_OER']['image_tmp_name']) ? URLHelper::getURL("dispatch.php/oer/mymaterial/show_tmp_image") : $material->getLogoURL()) ?>"
+                           data-customlogo="<?= !empty($_SESSION['NEW_OER']['image_tmp_name']) || $material['front_image_content_type'] ? 1 : 0 ?>">
                         <?= _('Vorschau-Bilddatei (optional)') ?>
                         <input type="file"
                                name="image"
@@ -67,7 +67,7 @@
 
 
 
-            <? if (!$_SESSION['NEW_OER']['tmp_name']) : ?>
+            <? if (!empty($_SESSION['NEW_OER']['tmp_name'])) : ?>
                 <label class="file drag-and-drop"
                        data-filename="<?= htmlReady($material['filename']) ?>"
                        data-filesize="<?= htmlReady(!$material->isNew() ? filesize($material->getFilePath()) : "") ?>"
@@ -84,7 +84,7 @@
             <label>
                 <?= _('Beschreibung') ?>
                 <textarea
-                        name="data[description]"><?= htmlReady($material['description'] ?: $template['description']) ?></textarea>
+                        name="data[description]"><?= htmlReady($material['description'] ?: $template['description'] ?? '') ?></textarea>
             </label>
 
             <label>
@@ -121,7 +121,7 @@
             <label>
                 <?= _('Vorschau-URL (optional)') ?>
                 <input type="text" name="data[player_url]"
-                       value="<?= htmlReady($material['player_url'] ?: $template['player_url']) ?>">
+                       value="<?= htmlReady($material['player_url'] ?: $template['player_url'] ?? '') ?>">
             </label>
 
             <? if (!$material->isNew()) : ?>
@@ -144,7 +144,7 @@
                                             <?= htmlReady($user['name']) ?>
                                         </span>
                                             <? if (count($material->users) > 1) : ?>
-                                                <?= Icon::create('trash')->asImg(16, ['class' => "text-bottom", 'title' => _('Person als Autor entfernen.')]) ?>
+                                                <?= Icon::create('trash')->asImg(['class' => "text-bottom", 'title' => _('Person als Autor entfernen.')]) ?>
                                             <? endif ?>
                                         </div>
                                     </label>
@@ -186,8 +186,10 @@
                 foreach ($material->getTopics() as $tag) {
                     $tags[] = $tag['name'];
                 }
-                foreach ((array) $template['tags'] as $tag) {
-                    $tags[] = $tag;
+                if (!empty($template['tags'])) {
+                    foreach ((array)$template['tags'] as $tag) {
+                        $tags[] = $tag;
+                    }
                 }
                 ?>
 
@@ -233,7 +235,7 @@
                 <div id="difficulty_slider_edit" style="margin-left: 5px; margin-right: 9px;"></div>
             </div>
 
-            <? if ($template['module_id']) : ?>
+            <? if (!empty($template['module_id'])) : ?>
                 <input type="hidden"
                        name="module_id"
                        value="<?= htmlReady($template['module_id']) ?>">
@@ -273,7 +275,7 @@
             </fieldset>
 
         <? endif ?>
-        <? if ($template['redirect_url']) : ?>
+        <? if (!empty($template['redirect_url'])) : ?>
             <input type="hidden"
                    name="redirect_url"
                    value="<?= htmlReady($template['redirect_url']) ?>">
diff --git a/lib/classes/StudipRangeTree.class.php b/lib/classes/StudipRangeTree.class.php
index 36f7314782e289ad6e052d869941109b9c98b509..cf88d231cf0de78408789d5ddc29cfdb5187eb15 100644
--- a/lib/classes/StudipRangeTree.class.php
+++ b/lib/classes/StudipRangeTree.class.php
@@ -111,10 +111,10 @@ class StudipRangeTree extends TreeAbstract
     * useful for the user rights management
     * @access   public
     * @param    string  $item_id
-    * @return   array   of primary keys from table "institute"
+    * @return  bool|array   of primary keys from table "institute"
     */
     function getAdminRange($item_id) {
-        if (!$this->tree_data[$item_id]) {
+        if (empty($this->tree_data[$item_id])) {
             return false;
         }
 
diff --git a/lib/classes/StudipRangeTreeViewAdmin.class.php b/lib/classes/StudipRangeTreeViewAdmin.class.php
index 6c5f3499752d709170d9a5b94e417b5b949fd817..777037aafbce4406e60cba5ec0da8cd2d3668036 100644
--- a/lib/classes/StudipRangeTreeViewAdmin.class.php
+++ b/lib/classes/StudipRangeTreeViewAdmin.class.php
@@ -112,7 +112,11 @@ class StudipRangeTreeViewAdmin extends TreeView{
                         }
                     }
 
-                    $tmp = $this->tree->getAdminRange($this->tree->tree_data[$key]['parent_id']);
+                    if (isset($this->tree->tree_data[$key])) {
+                        $tmp = $this->tree->getAdminRange($this->tree->tree_data[$key]['parent_id']);
+                    } else {
+                        $tmp = [];
+                    }
 
                     if(!empty($tmp)) {
                         foreach($tmp as $i) {
diff --git a/lib/classes/calendar/SingleCalendar.php b/lib/classes/calendar/SingleCalendar.php
index 2b19de8bfd04df2e73b6804c7128bf1aa1523658..bd968262c1194a82f1950f5e2abe3f253b54290b 100644
--- a/lib/classes/calendar/SingleCalendar.php
+++ b/lib/classes/calendar/SingleCalendar.php
@@ -1234,10 +1234,10 @@ class SingleCalendar
         $properties = $event->getProperties();
         if (is_array($restrictions)) {
             foreach ($restrictions as $property_name => $restriction) {
-                if (is_array($restriction)) {
+                if (is_array($restriction) && isset($properties[mb_strtoupper($property_name)])) {
                     return in_array($properties[mb_strtoupper($property_name)], $restriction);
                 } else if ($restriction != '') {
-                    return $properties[mb_strtoupper($property_name)] == $restriction;
+                    return isset($properties[mb_strtoupper($property_name)]) && $properties[mb_strtoupper($property_name)] === $restriction;
                 }
             }
             return true;
diff --git a/lib/classes/coursewizardsteps/StudyAreasWizardStep.php b/lib/classes/coursewizardsteps/StudyAreasWizardStep.php
index c0edda89a230b51cc45baa0a32e4c49c26aede1b..668a54e0928dfd0279e8867a11996a2fb75e6a01 100644
--- a/lib/classes/coursewizardsteps/StudyAreasWizardStep.php
+++ b/lib/classes/coursewizardsteps/StudyAreasWizardStep.php
@@ -32,8 +32,7 @@ class StudyAreasWizardStep implements CourseWizardStep
         // Load template from step template directory.
         $factory = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH'].'/app/views/course/wizard/steps');
         $tpl = $factory->open('studyareas/index');
-        if ($values['studyareas'])
-        {
+        if (!empty($values['studyareas'])) {
             $tree = $this->buildPartialSemTree(StudipStudyArea::backwards(StudipStudyArea::findMany($values['studyareas'])));
             $tpl->set_attribute('assigned', $tree);
         } else {
@@ -80,8 +79,8 @@ class StudyAreasWizardStep implements CourseWizardStep
             }
         }
         $tpl->set_attribute('tree', $tree);
-        $tpl->set_attribute('ajax_url', $values['ajax_url'] ?: URLHelper::getLink('dispatch.php/course/wizard/ajax'));
-        $tpl->set_attribute('no_js_url', $values['no_js_url'] ? : 'dispatch.php/course/wizard/forward/'.$stepnumber.'/'.$temp_id);
+        $tpl->set_attribute('ajax_url', $values['ajax_url'] ?? URLHelper::getLink('dispatch.php/course/wizard/ajax'));
+        $tpl->set_attribute('no_js_url', $values['no_js_url'] ?? 'dispatch.php/course/wizard/forward/'.$stepnumber.'/'.$temp_id);
         $tpl->set_attribute('stepnumber', $stepnumber);
         $tpl->set_attribute('temp_id', $temp_id);
         return $tpl->render();
diff --git a/lib/classes/sidebar/RoomSearchWidget.class.php b/lib/classes/sidebar/RoomSearchWidget.class.php
index af7a8192fcf760aaaa3c022585fe58058f55c862..5b6aa49c4de499747c93dc07beac447d884f12d1 100644
--- a/lib/classes/sidebar/RoomSearchWidget.class.php
+++ b/lib/classes/sidebar/RoomSearchWidget.class.php
@@ -222,7 +222,7 @@ class RoomSearchWidget extends SidebarWidget
                         Request::get($name . '_semester_id');
                 }
             } else {
-                if ($data['switch']) {
+                if (!empty($data['switch'])) {
                     if (Request::get($name . '_enabled')) {
                         $data['enabled'] = true;
                     } else {
@@ -399,7 +399,7 @@ class RoomSearchWidget extends SidebarWidget
         //since its begin and end date are set on the client side in
         //the special__available_range property when a semester is selected.
         $time_intervals = [];
-        if ($this->selected_criteria['special__time_range']) {
+        if (!empty($this->selected_criteria['special__time_range'])) {
             $time_range_criteria = $this->selected_criteria['special__time_range'];
 
             //Get and check day of week:
diff --git a/lib/models/CourseEvent.class.php b/lib/models/CourseEvent.class.php
index 930c57a37e25ebba82a2dd728fcaf045ad5b2bb8..2d564b5dd4f2af438dac998c8544de92fee6c172 100644
--- a/lib/models/CourseEvent.class.php
+++ b/lib/models/CourseEvent.class.php
@@ -210,7 +210,7 @@ class CourseEvent extends CourseDate implements Event
     {
         $title = _('Keine Berechtigung.');
         if ($this->havePermission(Event::PERMISSION_READABLE)) {
-            $description = trim($this->cycle->description) ?: '';
+            $description = $this->cycle ? trim($this->cycle->description) : '';
             if (sizeof($this->topics)) {
                 $title = $this->course->name.": ".implode(', ', $this->topics->pluck('title'));
             } else {
diff --git a/lib/models/OERHost.php b/lib/models/OERHost.php
index b323602ba2f568479e770a1d773593ef4fb55671..d0b1f6928a68fd0db5a5ae37e1929659679d232f 100644
--- a/lib/models/OERHost.php
+++ b/lib/models/OERHost.php
@@ -63,10 +63,13 @@ class OERHost extends OERIdentity
     public static function find($id)
     {
         $host = parent::find($id);
-        $class = $host['sorm_class'];
-        if ($class && ($class !== 'OERHost') && is_subclass_of($class, 'OERHost')) {
-            $data = $host->toRawArray();
-            $host = $class::buildExisting($data);
+
+        if ($host) {
+            $class = $host['sorm_class'];
+            if ($class && ($class !== 'OERHost') && is_subclass_of($class, 'OERHost')) {
+                $data = $host->toRawArray();
+                $host = $class::buildExisting($data);
+            }
         }
         return $host;
     }
diff --git a/public/admin_evaluation.php b/public/admin_evaluation.php
index 144e3f31dc7bc8c6b8dedc25037e57c8b8be629d..f702173df547c76214650b627a2fa3c715b7b1f5 100644
--- a/public/admin_evaluation.php
+++ b/public/admin_evaluation.php
@@ -76,6 +76,7 @@ if ((Context::getId()) && ($view == "eval_sem") || ($view == "eval_inst")) {
     $the_range = Request::option('rangeID');
 }
 
+$isUserrange = null;
 if ($the_range) {
     if (get_Username($the_range)) {
         $the_range = get_Username($the_range);
diff --git a/public/assets.php b/public/assets.php
index 8994b40f54ff5722116fd0619f1ae6133e943430..8e066859b3b6630e22a9797209aeb6bb552538c7 100644
--- a/public/assets.php
+++ b/public/assets.php
@@ -34,7 +34,7 @@ if (!$type || !$id) {
 } else {
     // Load asset
     $model = PluginAsset::find($id);
-    if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] && $model->chdate <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
+    if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $model->chdate <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
         // Cached and still valid
         $response->set_status(304);
     } else {
diff --git a/templates/calendar/calendar_view.php b/templates/calendar/calendar_view.php
index a397f0b4a9ee0528e4e86dfcfe2525377982c28b..db3cb36b941787473ae0d319ef8d51057fb80e1e 100644
--- a/templates/calendar/calendar_view.php
+++ b/templates/calendar/calendar_view.php
@@ -151,7 +151,9 @@ $cell_steps = $cell_height / 60;
                             $max = 0;
                             $current_matrix = $column->getMatrix();
                             for ($i = ($calc_entry['start'] + 1 + ($start_hour * 100)); $i < $calc_entry['end'] + ($start_hour * 100); $i++) {
-                                $max = max($max, $current_matrix[$i]);
+                                if (isset($current_matrix[$i])) {
+                                    $max = max($max, $current_matrix[$i]);
+                                }
                             }
 
                             // set height and width
diff --git a/templates/calendar/entries/entry.php b/templates/calendar/entries/entry.php
index 71d8a8fba3768570420e92bef12b7f02d9894961..1b4242d7b8eb1cafdba298013ee2b7eaecf83882 100644
--- a/templates/calendar/entries/entry.php
+++ b/templates/calendar/entries/entry.php
@@ -3,15 +3,15 @@
 $element_id = md5(uniqid());
 ?>
 
-<div id="schedule_entry_<?= $element_id ?>_<?= $entry['id'] ?>" class="schedule_entry <?= ((isset($entry['visible']) && !$entry['visible']) ? 'invisible_entry' : '') . ($entry['onClick'] ? " clickable" : "") ?>" style="top: <?= $top ?>px; height: <?= $height ?>px; width: <?= str_replace(',', '.', $width) ?>%<?= ($col > 0) ? ';left:'. str_replace(',', '.', $col * $width) .'%' : '' ?>" title="<?= htmlReady($entry['title']) ?>">
+<div id="schedule_entry_<?= $element_id ?>_<?= $entry['id'] ?? '' ?>" class="schedule_entry <?= ((isset($entry['visible']) && !$entry['visible']) ? 'invisible_entry' : '') . (!empty($entry['onClick']) ? " clickable" : "") ?>" style="top: <?= $top ?>px; height: <?= $height ?>px; width: <?= str_replace(',', '.', $width) ?>%<?= ($col > 0) ? ';left:'. str_replace(',', '.', $col * $width) .'%' : '' ?>" title="<?= htmlReady($entry['title']) ?>">
 
-    <a <?= $entry['url'] ? ' href="'.$entry['url'].'"' : '' ?>
-        <?= $entry['onClick'] ? 'onClick="STUDIP.Calendar.clickEngine('. $entry['onClick'].', this, event); return false;"' : '' ?>>
+    <a <?= !empty($entry['url']) ? ' href="'.$entry['url'].'"' : '' ?>
+        <?= !empty($entry['onClick']) ? 'onClick="STUDIP.Calendar.clickEngine('. $entry['onClick'].', this, event); return false;"' : '' ?>>
 
     <!-- for safari5 we need to set the height for the dl as well -->
-    <dl class="hidden-medium-up schedule-category<?= $entry['color']?> <?= $calendar_view->getReadOnly() ? '' : 'hover' ?>" style="height: <?= $height ?>px;">
+    <dl class="hidden-medium-up schedule-category<?= $entry['color'] ?? ''?> <?= $calendar_view->getReadOnly() ? '' : 'hover' ?>" style="height: <?= $height ?>px;">
         <dt>
-            <?= nl2br(htmlReady($entry['content'])) ?><br>
+            <?= nl2br(htmlReady($entry['content'] ?? '')) ?><br>
         </dt>
         <dd>
             <?= floor($entry['start']/100).":".(($entry['start']%100) < 10 ? "0" : "").($entry['start']%100) ?> - <?= floor($entry['end']/100).":".(($entry['end']%100) < 10 ? "0" : "").($entry['end']%100) ?><?= $entry['title'] ? ', <b>'. htmlReady($entry['title']) .'</b>' : '' ?>
@@ -22,7 +22,7 @@ $element_id = md5(uniqid());
             <?= floor($entry['start']/100).":".(($entry['start']%100) < 10 ? "0" : "").($entry['start']%100) ?> - <?= floor($entry['end']/100).":".(($entry['end']%100) < 10 ? "0" : "").($entry['end']%100) ?><?= $entry['title'] ? ', <b>'. htmlReady($entry['title']) .'</b>' : '' ?>
         </dt>
         <dd>
-            <?= nl2br(htmlReady($entry['content'])) ?><br>
+            <?= nl2br(htmlReady($entry['content'] ?? '')) ?><br>
         </dd>
     </dl>
 
diff --git a/templates/calendar/entries/icons.php b/templates/calendar/entries/icons.php
index 2e0f3d21582b6d6640644185f33ee3027a0efb69..c9fd74b03957dc17612f285a1021f3df195bae98 100644
--- a/templates/calendar/entries/icons.php
+++ b/templates/calendar/entries/icons.php
@@ -1,5 +1,5 @@
 <div id="schedule_icons_<?= $element_id ?>" class="schedule_icons">
-    <? if (is_array($entry['icons'])) foreach ($entry['icons'] as $icon) : ?>
+    <? if (!empty($entry['icons'])) foreach ($entry['icons'] as $icon) : ?>
         <? if($icon['url']) : ?>
         <a href="<?= $icon['url'] ?>" <?= $icon['onClick'] ? 'onClick="STUDIP.Calendar.clickEngine('. $icon['onClick'].', this, event); return false;"' : '' ?>>
             <?= Assets::img($icon['image'], ['title' => htmlReady($icon['title']), 'alt' => htmlReady($icon['title'])]) ?>