diff --git a/lib/classes/ForumAbo.php b/lib/classes/ForumAbo.php
index 334b42455533d77a947a3fd3cf6c239ba9ff34ce..2fdd617c59d3669f015191aaea46e506f8a23cbe 100644
--- a/lib/classes/ForumAbo.php
+++ b/lib/classes/ForumAbo.php
@@ -77,7 +77,7 @@ class ForumAbo
     {
         // send message to all abo-users
         $db = DBManager::get();
-        $messaging = new ForumBulkMail();
+        $messaging = new messaging();
 
         // get all parent topic-ids, to find out which users to notify
         $path = ForumEntry::getPathToPosting($topic_id);
@@ -95,9 +95,11 @@ class ForumAbo
         // get details for topic
         $topic = ForumEntry::getConstraints($topic_id);
 
-        $template = $GLOBALS['template_factory']->open('mail/forum_notification');
+        if (!$topic) {
+            return;
+        }
 
-        // notify users
+        $template = $GLOBALS['template_factory']->open('mail/forum_notification');// notify users
         while ($data = $stmt->fetch(PDO::FETCH_ASSOC)) {
             $user_id = $data['user_id'];
 
@@ -149,8 +151,6 @@ class ForumAbo
                 );
             }
         }
-
-        $messaging->bulkSend();
     }
 
     /**
diff --git a/lib/classes/ForumActivity.php b/lib/classes/ForumActivity.php
index a6a685d464618eddfa73911a64e11ee8adec0ca5..0f6cbf8160399b35a8545211b347af76a2faa813 100644
--- a/lib/classes/ForumActivity.php
+++ b/lib/classes/ForumActivity.php
@@ -129,7 +129,7 @@ class ForumActivity
             $data['actor_id']   = '';
         }
 
-        $activity = Studip\Activity\Activity::create($data);
+        Studip\Activity\Activity::create($data);
     }
 
     /**
@@ -140,7 +140,7 @@ class ForumActivity
      */
     private static function getPostUsername($post)
     {
-        if ($post['anonymous']) {
+        if (!empty($post['anonymous'])) {
             return _('Anonym');
         }
 
diff --git a/lib/classes/ForumBulkMail.php b/lib/classes/ForumBulkMail.php
deleted file mode 100644
index 6c2f666baa4ac18bb40c7d989e905a8f0d56c83d..0000000000000000000000000000000000000000
--- a/lib/classes/ForumBulkMail.php
+++ /dev/null
@@ -1,128 +0,0 @@
-<?php
-/**
- * ForumBulkMail.php - Experimental mailer to handle large amounts of mails at high speed
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 3 of
- * the License, or (at your option) any later version.
- *
- * @author      Till Glöggler <tgloeggl@uos.de>
- * @license     http://www.gnu.org/licenses/gpl-3.0.html GPL version 3
- * @category    Stud.IP
- */
-
-class ForumBulkMail extends messaging
-{
-    var $bulk_mail;
-
-    /**
-     * Overwrites the parent method. This method combines messages with the same
-     * content and prepares them for sending them as a mail with multiple
-     * recepients instead of one mail for each recipient.
-     * The actual sending task is done bulkSend().
-     *
-     * @global object $user
-     *
-     * @param string $rec_user_id  user_id of recipient
-     * @param string $snd_user_id  user_id of sender
-     * @param string $message      the message
-     * @param string $subject      subject for the message
-     * @param string $message_id   the message_id in the database
-     */
-    public function sendingEmail($rec_user_id, $snd_user_id, $message, $subject, $message_id)
-    {
-        $receiver = User::find($rec_user_id);
-
-        if ($receiver && $receiver->email) {
-            setTempLanguage($receiver->id);
-
-            if (empty($this->bulk_mail[md5($message)][getenv('LANG')])) {
-
-                $title = "[Stud.IP - " . Config::get()->UNI_NAME_CLEAN . "] ".stripslashes(kill_format(str_replace(["\r","\n"], '', $subject)));
-
-                if ($snd_user_id != "____%system%____") {
-                    $sender = User::find($snd_user_id);
-                    $reply_to = $sender->email;
-                }
-
-                $template = $GLOBALS['template_factory']->open('mail/text');
-                $template->message      = kill_format(stripslashes($message));
-                $template->rec_fullname = $receiver->getFullName();
-                $mailmessage = $template->render();
-
-                $template = $GLOBALS['template_factory']->open('mail/html');
-                $template->lang         = getUserLanguagePath($rec_user_id);
-                $template->message      = stripslashes($message);
-                $template->rec_fullname = $receiver->getFullName();
-                $mailhtml = $template->render();
-
-                $this->bulk_mail[md5($message)][getenv('LANG')] = [
-                    'text'       => $mailmessage,
-                    'html'       => $mailhtml,
-                    'title'      => $title,
-                    'reply_to'   => $reply_to,
-                    'message_id' => $message_id,
-                    'users'      => []
-                ];
-            }
-
-            $this->bulk_mail[md5($message)][getenv('LANG')]['users'][$receiver->id] = $receiver->email;
-
-            restoreLanguage();
-        }
-    }
-
-
-    /**
-     * Sends the collected messages from sendingMail as e-mail.
-     */
-    public function bulkSend()
-    {
-        // if nothing to do, return
-        if (empty($this->bulk_mail)) {
-            return;
-        }
-
-        // send a mail, for each language one
-        foreach ($this->bulk_mail as $lang_data) {
-            foreach ($lang_data as $data) {
-                $mail = new StudipMail();
-                $mail->setSubject($data['title']);
-
-                foreach ($data['users'] as $user_id => $to) {
-                    $mail->addRecipient($to, get_fullname($user_id), 'Bcc');
-                }
-
-                $mail->setBodyText($data['text']);
-
-                if (mb_strlen($data['reply_to'])) {
-                    $mail->setSenderEmail($data['reply_to']);
-                }
-
-                $user_cfg = UserConfig::get($user_id);
-                if ($user_cfg->MAIL_AS_HTML) {
-                    $mail->setBodyHtml($data['html']);
-                }
-
-                if ($GLOBALS["ENABLE_EMAIL_ATTACHMENTS"]){
-                    $message = Message::find($data['message_id']);
-
-                    $current_user = User::findCurrent();
-
-                    $message_folder = MessageFolder::findTopFolder($message->id);
-
-                    $attachments = FileManager::getFolderFilesRecursive(
-                        $message_folder,
-                        $current_user->id
-                    );
-
-                    foreach ($attachments as $attachment) {
-                        $mail->addStudipAttachment($attachment);
-                    }
-                }
-                $mail->send();
-            }
-        }
-    }
-}
diff --git a/lib/classes/ForumEntry.php b/lib/classes/ForumEntry.php
index 7ac5306eb62e73198569d87a3e7755b4b68a2bd1..df3fbf9334edba9067fb2e17b84970bf03ced5db 100644
--- a/lib/classes/ForumEntry.php
+++ b/lib/classes/ForumEntry.php
@@ -124,7 +124,7 @@ class ForumEntry  implements PrivacyObject
      * Get author and time of an edited forum entry.
      *
      * @param string  $description  Database entry of forum entry's body.
-     * @return array    Associative array containing author and time.
+     * @return array|bool   Associative array containing author and time.
      *         boolean  False if edit tag was not found.
      */
     public static function getEditInfo($description) {
@@ -138,7 +138,7 @@ class ForumEntry  implements PrivacyObject
     /**
      * Remove all quote blocks AND the quoted text from a forum post.
      *
-     * @param String $string The string to remove the quote blocks from
+     * @param String $description The string to remove the quote blocks from
      * @return String the posting without the [quote]-blocks (not just tags!)
      */
     public static function removeQuotes($description)
@@ -179,14 +179,16 @@ class ForumEntry  implements PrivacyObject
      * returns the entry for the passed topic_id
      *
      * @param  string  $topic_id
-     * @return array   array('lft' => ..., 'rgt' => ..., seminar_id => ...)
+     * @return array | bool  array('lft' => ..., 'rgt' => ..., seminar_id => ...)
      *
      * @throws Exception
      */
     public static function getConstraints($topic_id)
     {
         //very bad performance if topic_id is 0 or false
-        if (!$topic_id) return false;
+        if (!$topic_id) {
+            return false;
+        }
 
         // look up the range of postings
         $range_stmt = DBManager::get()->prepare("SELECT *
@@ -194,7 +196,6 @@ class ForumEntry  implements PrivacyObject
         $range_stmt->execute([$topic_id]);
         if (!$data = $range_stmt->fetch(PDO::FETCH_ASSOC)) {
             return false;
-            // throw new Exception("Could not find entry with id >>$topic_id<< in forum_entries, " . __FILE__ . " on line " . __LINE__);
         }
 
         if ($data['depth'] == 1) {
@@ -231,10 +232,13 @@ class ForumEntry  implements PrivacyObject
     public static function getChildTopicIds($topic_id)
     {
         $constraints = ForumEntry::getConstraints($topic_id);
+        if (!$constraints) {
+            return [];
+        }
 
         $stmt = DBManager::get()->prepare("SELECT topic_id
-            FROM forum_entries WHERE lft >= ? AND rgt <= ?
-                AND seminar_id = ?");
+        FROM forum_entries WHERE lft >= ? AND rgt <= ?
+            AND seminar_id = ?");
         $stmt->execute([$constraints['lft'], $constraints['rgt'], $constraints['seminar_id']]);
 
         return $stmt->fetchAll(PDO::FETCH_COLUMN);
@@ -256,13 +260,20 @@ class ForumEntry  implements PrivacyObject
             $constraint = ForumEntry::getConstraints($topic_id);
         }
 
+        if (!$constraint) {
+            return 0;
+        }
         // this calculation only works for postings
-        if ($constraint['depth'] <= 2) return ForumHelpers::getPage();
+        if ($constraint['depth'] <= 2) {
+            return ForumHelpers::getPage();
+        }
 
         if ($parent_id = ForumEntry::getParentTopicId($topic_id)) {
             $parent_constraint = ForumEntry::getConstraints($parent_id);
 
-            return ceil((($constraint['lft'] - $parent_constraint['lft'] + 3) / 2) / ForumEntry::POSTINGS_PER_PAGE);
+            if ($parent_constraint) {
+                return ceil((($constraint['lft'] - $parent_constraint['lft'] + 3) / 2) / ForumEntry::POSTINGS_PER_PAGE);
+            }
         }
 
         return 0;
@@ -278,6 +289,10 @@ class ForumEntry  implements PrivacyObject
     {
         $constraint = ForumEntry::getConstraints($parent_id);
 
+        if (!$constraint) {
+            return null;
+        }
+
         // take users visitdate into account
         $visitdate = ForumVisit::getLastVisit($constraint['seminar_id']);
 
@@ -297,23 +312,21 @@ class ForumEntry  implements PrivacyObject
      * or false if the postings itself is the latest
      *
      * @param string $parent_id the node to lookup the childs in
-     * @return mixed the data for the latest postings or false
+     * @return array | bool the data for the latest postings or false
      */
     public static function getLatestPosting($parent_id)
     {
         $constraint = ForumEntry::getConstraints($parent_id);
+        if (!$constraint) {
+            return false;
+        }
 
-        // get last entry
         $stmt = DBManager::get()->prepare("SELECT * FROM forum_entries
-            WHERE lft > ? AND rgt < ? AND seminar_id = ?
-            ORDER BY mkdate DESC LIMIT 1");
+        WHERE lft > ? AND rgt < ? AND seminar_id = ?
+        ORDER BY mkdate DESC LIMIT 1");
         $stmt->execute([$constraint['lft'], $constraint['rgt'], $constraint['seminar_id']]);
 
-        if (!$data = $stmt->fetch(PDO::FETCH_ASSOC)) {
-            return false;
-        }
-
-        return $data;
+        return $stmt->fetch(PDO::FETCH_ASSOC) ?: false;
     }
 
     /**
@@ -327,20 +340,22 @@ class ForumEntry  implements PrivacyObject
     public static function getPathToPosting($topic_id)
     {
         $data = ForumEntry::getConstraints($topic_id);
+        if (!$data) {
+            return [];
+        }
+
         $ret = [];
 
         $stmt = DBManager::get()->prepare("SELECT * FROM forum_entries
-            WHERE lft <= ? AND rgt >= ? AND seminar_id = ? ORDER BY lft ASC");
+        WHERE lft <= ? AND rgt >= ? AND seminar_id = ? ORDER BY lft ASC");
         $stmt->execute([$data['lft'], $data['rgt'], $data['seminar_id']]);
 
         while ($data = $stmt->fetch(PDO::FETCH_ASSOC)) {
             $ret[$data['topic_id']] = $data;
             $ret[$data['topic_id']]['id'] = $data['topic_id'];
         }
-
         // set the name of the first entry to the name of the category the entry is in
-        if (sizeof($ret) > 1) {
-            reset($ret);
+        if (count($ret) > 1) {
             $tmp = array_slice($ret, 1, 1);
             $area = array_pop($tmp);
             $top  = current($ret);
@@ -365,9 +380,7 @@ class ForumEntry  implements PrivacyObject
     {
         // use only the part of the path until the thread, no posting title
         $postings = array_slice(self::getPathToPosting($topic_id), 0, 3);
-
-        // var_dump($postings);
-
+        $ret = [];
         foreach ($postings as $post) {
             if ($post['name']) {
                 $ret[$post['id']] = $post['name'];
@@ -393,8 +406,6 @@ class ForumEntry  implements PrivacyObject
             $desc_short = ForumEntry::br2space(ForumEntry::killFormat($data['content']));
             if (mb_strlen($desc_short) > (ForumEntry::THREAD_PREVIEW_LENGTH + 2)) {
                 $desc_short = mb_substr($desc_short, 0, ForumEntry::THREAD_PREVIEW_LENGTH) . '...';
-            } else {
-                $desc_short = $desc_short;
             }
 
             $posting_list[$data['topic_id']] = [
@@ -463,6 +474,9 @@ class ForumEntry  implements PrivacyObject
         $sort_order = 'DESC', $start = 0, $limit = ForumEntry::POSTINGS_PER_PAGE)
     {
         $constraint = ForumEntry::getConstraints($parent_id);
+        if (!$constraint) {
+            return [];
+        }
         $seminar_id = $constraint['seminar_id'];
         $depth      = $constraint['depth'] + 1;
 
@@ -596,6 +610,10 @@ class ForumEntry  implements PrivacyObject
             case 'list':
                 $constraint = ForumEntry::getConstraints($parent_id);
 
+                if (!$constraint) {
+                    return [];
+                }
+
                 // purpose of the following query is to retrieve the threads
                 // for an area ordered by the mkdate of their latest posting
                 $stmt = DBManager::get()->prepare("SELECT SQL_CALC_FOUND_ROWS
@@ -624,6 +642,9 @@ class ForumEntry  implements PrivacyObject
 
             case 'newest':
                 $constraint = ForumEntry::getConstraints($parent_id);
+                if (!$constraint) {
+                    return [];
+                }
                 $last_visit_date = ForumVisit::getLastVisit($constraint['seminar_id']);
 
                 // get postings
@@ -672,6 +693,9 @@ class ForumEntry  implements PrivacyObject
 
             case 'dump':
                 $constraint = ForumEntry::getConstraints($parent_id);
+                if (!$constraint) {
+                    return [];
+                }
                 $seminar_id = $constraint['seminar_id'];
                 $depth      = $constraint['depth'] + 1;
 
@@ -687,7 +711,9 @@ class ForumEntry  implements PrivacyObject
 
             case 'flat':
                 $constraint = ForumEntry::getConstraints($parent_id);
-
+                if (!$constraint) {
+                    return [];
+                }
                 $stmt = DBManager::get()->prepare("SELECT SQL_CALC_FOUND_ROWS * FROM forum_entries
                     WHERE lft > ? AND rgt < ? AND seminar_id = ? AND depth = ?
                     ORDER BY name ASC");
@@ -703,8 +729,6 @@ class ForumEntry  implements PrivacyObject
                     $desc_short = ForumEntry::br2space(ForumEntry::killFormat($data['content']));
                     if (mb_strlen($desc_short) > (ForumEntry::THREAD_PREVIEW_LENGTH + 2)) {
                         $desc_short = mb_substr($desc_short, 0, ForumEntry::THREAD_PREVIEW_LENGTH) . '...';
-                    } else {
-                        $desc_short = $desc_short;
                     }
                     $posting_list[$data['topic_id']] = [
                         'author'          => $data['author'],
@@ -727,7 +751,9 @@ class ForumEntry  implements PrivacyObject
 
             case 'depth_to_large':
                 $constraint = ForumEntry::getConstraints($parent_id);
-
+                if (!$constraint) {
+                    return [];
+                }
                 $stmt = DBManager::get()->prepare("SELECT SQL_CALC_FOUND_ROWS * FROM forum_entries
                     WHERE lft > ? AND rgt < ? AND seminar_id = ? AND depth > 3
                     ORDER BY name ASC");
@@ -753,7 +779,9 @@ class ForumEntry  implements PrivacyObject
     public static function getLatestSince($parent_id, $start_date, $end_date)
     {
         $constraint = ForumEntry::getConstraints($parent_id);
-
+        if (!$constraint) {
+            return [];
+        }
         $stmt = DBManager::get()->prepare("SELECT SQL_CALC_FOUND_ROWS * FROM forum_entries
             WHERE lft > ? AND rgt < ? AND seminar_id = ?
                 AND mkdate BETWEEN ? AND ?
@@ -839,7 +867,7 @@ class ForumEntry  implements PrivacyObject
      * returns the entry for the passed topic_id
      *
      * @param string $topic_id
-     * @return array hash-array with the entries fields
+     * @return array | false hash-array with the entries fields
      */
     public static function getEntry($topic_id)
     {
@@ -856,6 +884,9 @@ class ForumEntry  implements PrivacyObject
     public static function countEntries($parent_id)
     {
         $data = ForumEntry::getConstraints($parent_id);
+        if (!$data) {
+            return 0;
+        }
         return max((($data['rgt'] - $data['lft'] - 1) / 2) + 1, 0);
     }
 
@@ -923,23 +954,27 @@ class ForumEntry  implements PrivacyObject
     {
         $constraint = ForumEntry::getConstraints($parent_id);
 
+        if (!$constraint) {
+            return;
+        }
+
         // #TODO: Zusammenfassen in eine Transaktion!!!
         DBManager::get()->exec('UPDATE forum_entries SET lft = lft + 2
-            WHERE lft > '. $constraint['rgt'] ." AND seminar_id = '". $constraint['seminar_id'] ."'");
+        WHERE lft > '. $constraint['rgt'] ." AND seminar_id = '". $constraint['seminar_id'] ."'");
         DBManager::get()->exec('UPDATE forum_entries SET rgt = rgt + 2
-            WHERE rgt >= '. $constraint['rgt'] ." AND seminar_id = '". $constraint['seminar_id'] ."'");
+        WHERE rgt >= '. $constraint['rgt'] ." AND seminar_id = '". $constraint['seminar_id'] ."'");
 
         $stmt = DBManager::get()->prepare("INSERT INTO forum_entries
-            (topic_id, seminar_id, user_id, name, content, mkdate, latest_chdate,
-                chdate, author, author_host, lft, rgt, depth, anonymous)
-            VALUES (? ,?, ?, ?, ?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), ?, ?, ?, ?, ?, ?)");
+        (topic_id, seminar_id, user_id, name, content, mkdate, latest_chdate,
+            chdate, author, author_host, lft, rgt, depth, anonymous)
+        VALUES (? ,?, ?, ?, ?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), ?, ?, ?, ?, ?, ?)");
         $stmt->execute([$data['topic_id'], $data['seminar_id'], $data['user_id'],
             $data['name'], $data['content'], $data['author'], $data['author_host'],
             $constraint['rgt'], $constraint['rgt'] + 1, $constraint['depth'] + 1, $data['anonymous'] ?? 0]);
 
         // update "latest_chdate" for easier sorting of actual threads
         DBManager::get()->exec("UPDATE forum_entries SET latest_chdate = UNIX_TIMESTAMP()
-            WHERE topic_id = '" . $constraint['topic_id'] . "'");
+        WHERE topic_id = '" . $constraint['topic_id'] . "'");
 
         NotificationCenter::postNotification('ForumAfterInsert', $data['topic_id'], $data);
     }
@@ -957,20 +992,23 @@ class ForumEntry  implements PrivacyObject
     public static function update($topic_id, $name, $content)
     {
         $post = ForumEntry::getConstraints($topic_id);
+        if (!$post) {
+            return;
+        }
 
         if (time() - $post['mkdate'] > 5 * 60) {
             $content = ForumEntry::appendEdit($content);
         }
 
         $stmt = DBManager::get()->prepare("UPDATE forum_entries
-            SET name = ?, content = ?, chdate = UNIX_TIMESTAMP(), latest_chdate = UNIX_TIMESTAMP()
-            WHERE topic_id = ?");
+        SET name = ?, content = ?, chdate = UNIX_TIMESTAMP(), latest_chdate = UNIX_TIMESTAMP()
+        WHERE topic_id = ?");
         $stmt->execute([$name, $content, $topic_id]);
 
         // update "latest_chdate" for easier sorting of actual threads
         $parent_id = ForumEntry::getParentTopicId($topic_id);
         DBManager::get()->exec("UPDATE forum_entries SET latest_chdate = UNIX_TIMESTAMP()
-            WHERE topic_id = '" . $parent_id . "'");
+        WHERE topic_id = '" . $parent_id . "'");
 
         $post['name']    = $name;
         $post['content'] = $content;
@@ -987,57 +1025,64 @@ class ForumEntry  implements PrivacyObject
      */
     public static function delete($topic_id)
     {
-        $post   = ForumEntry::getConstraints($topic_id);
-        $parent = ForumEntry::getConstraints(ForumEntry::getParentTopicId($topic_id));
+        $post = ForumEntry::getConstraints($topic_id);
 
-        NotificationCenter::postNotification('ForumBeforeDelete', $topic_id, $post);
+        if ($post) {
+            NotificationCenter::postNotification('ForumBeforeDelete', $topic_id, $post);
 
-        // #TODO: Zusammenfassen in eine Transaktion!!!
-        // get all entry-ids to delete them from the category-reference-table
-        $stmt = DBManager::get()->prepare("SELECT topic_id FROM forum_entries
+            // #TODO: Zusammenfassen in eine Transaktion!!!
+            // get all entry-ids to delete them from the category-reference-table
+            $stmt = DBManager::get()->prepare("SELECT topic_id FROM forum_entries
             WHERE seminar_id = ? AND lft >= ? AND rgt <= ? AND depth = 1");
-        $stmt->execute([$post['seminar_id'], $post['lft'], $post['rgt']]);
-        $ids = $stmt->fetchAll(PDO::FETCH_COLUMN);
+            $stmt->execute([$post['seminar_id'], $post['lft'], $post['rgt']]);
+            $ids = $stmt->fetchAll(PDO::FETCH_COLUMN);
 
-        if ($ids != false && !is_array($ids)) $ids = [$ids];
+            if ($ids != false && !is_array($ids)) {
+                $ids = [$ids];
+            }
 
-        if (!empty($ids)) {
-            $stmt = DBManager::get()->prepare("DELETE FROM forum_categories_entries
+            if (!empty($ids)) {
+                $stmt = DBManager::get()->prepare("DELETE FROM forum_categories_entries
                 WHERE topic_id IN (:ids)");
-            $stmt->bindParam(':ids', $ids, StudipPDO::PARAM_ARRAY);
-            $stmt->execute();
-        }
+                $stmt->bindParam(':ids', $ids, StudipPDO::PARAM_ARRAY);
+                $stmt->execute();
+            }
 
-        // delete all entries
-        $stmt = DBManager::get()->prepare("DELETE FROM forum_entries
+            // delete all entries
+            $stmt = DBManager::get()->prepare("DELETE FROM forum_entries
             WHERE seminar_id = ? AND lft >= ? AND rgt <= ?");
 
-        $stmt->execute([$post['seminar_id'], $post['lft'], $post['rgt']]);
+            $stmt->execute([$post['seminar_id'], $post['lft'], $post['rgt']]);
 
-        // update lft and rgt
-        $diff = $post['rgt'] - $post['lft'] + 1;
-        $stmt = DBManager::get()->prepare("UPDATE forum_entries SET lft = lft - $diff
+            // update lft and rgt
+            $diff = $post['rgt'] - $post['lft'] + 1;
+            $stmt = DBManager::get()->prepare("UPDATE forum_entries SET lft = lft - $diff
             WHERE lft > ? AND seminar_id = ?");
-        $stmt->execute([$post['rgt'], $post['seminar_id']]);
+            $stmt->execute([$post['rgt'], $post['seminar_id']]);
 
-        $stmt = DBManager::get()->prepare("UPDATE forum_entries SET rgt = rgt - $diff
+            $stmt = DBManager::get()->prepare("UPDATE forum_entries SET rgt = rgt - $diff
             WHERE rgt > ? AND seminar_id = ?");
-        $stmt->execute([$post['rgt'], $post['seminar_id']]);
+            $stmt->execute([$post['rgt'], $post['seminar_id']]);
+
+        }
 
+        $parent = ForumEntry::getConstraints(ForumEntry::getParentTopicId($topic_id));
 
-        // set the latest_chdate to the latest child's chdate
-        $stmt = DBManager::get()->prepare("SELECT chdate FROM forum_entries
+        if ($parent) {
+            // set the latest_chdate to the latest child's chdate
+            $stmt = DBManager::get()->prepare("SELECT chdate FROM forum_entries
             WHERE lft > ? AND rgt < ? AND seminar_id = ?
             ORDER BY chdate DESC LIMIT 1");
-        $stmt->execute([$parent['lft'] ?? null, $parent['rgt'] ?? null, $parent['seminar_id'] ?? null]);
-        $chdate = $stmt->fetchColumn();
+            $stmt->execute([$parent['lft'] ?? null, $parent['rgt'] ?? null, $parent['seminar_id'] ?? null]);
+            $chdate = $stmt->fetchColumn();
 
-        $stmt_insert = DBManager::get()->prepare("UPDATE forum_entries
+            $stmt_insert = DBManager::get()->prepare("UPDATE forum_entries
             SET chdate = ? WHERE topic_id = ?");
-        if ($chdate) {
-            $stmt_insert->execute([$chdate, $parent['topic_id']]);
-        } else {
-            $stmt_insert->execute([$parent['chdate'], $parent['topic_id']]);
+            if ($chdate) {
+                $stmt_insert->execute([$chdate, $parent['topic_id']]);
+            } else {
+                $stmt_insert->execute([$parent['chdate'], $parent['topic_id']]);
+            }
         }
     }
 
@@ -1053,64 +1098,68 @@ class ForumEntry  implements PrivacyObject
     {
         // #TODO: Zusammenfassen in eine Transaktion!!!
         $constraints = ForumEntry::getConstraints($topic_id);
-
-        // move the affected entries "outside" the tree
-        $stmt = DBManager::get()->prepare("UPDATE forum_entries
+        if ($constraints) {
+            // move the affected entries "outside" the tree
+            $stmt = DBManager::get()->prepare("UPDATE forum_entries
             SET lft = lft * -1, rgt = rgt * -1
             WHERE seminar_id = ? AND lft >= ? AND rgt <= ?");
-        $stmt->execute([$constraints['seminar_id'], $constraints['lft'], $constraints['rgt']]);
+            $stmt->execute([$constraints['seminar_id'], $constraints['lft'], $constraints['rgt']]);
 
-        // update the lft and rgt values of the parent to reflect the "deletion"
-        $diff = $constraints['rgt'] - $constraints['lft'] + 1;
-        $stmt = DBManager::get()->prepare("UPDATE forum_entries SET lft = lft - ?
+            // update the lft and rgt values of the parent to reflect the "deletion"
+            $diff = $constraints['rgt'] - $constraints['lft'] + 1;
+            $stmt = DBManager::get()->prepare("UPDATE forum_entries SET lft = lft - ?
             WHERE lft > ? AND seminar_id = ?");
-        $stmt->execute([$diff, $constraints['rgt'], $constraints['seminar_id']]);
+            $stmt->execute([$diff, $constraints['rgt'], $constraints['seminar_id']]);
 
-        $stmt = DBManager::get()->prepare("UPDATE forum_entries SET rgt = rgt - ?
+            $stmt = DBManager::get()->prepare("UPDATE forum_entries SET rgt = rgt - ?
             WHERE rgt > ? AND seminar_id = ?");
-        $stmt->execute([$diff, $constraints['rgt'], $constraints['seminar_id']]);
+            $stmt->execute([$diff, $constraints['rgt'], $constraints['seminar_id']]);
 
-        // make some space by updating the lft and rgt values of the target node
-        $constraints_destination = ForumEntry::getConstraints($destination);
-        $size = $constraints['rgt'] - $constraints['lft'] + 1;
+            // make some space by updating the lft and rgt values of the target node
+            $constraints_destination = ForumEntry::getConstraints($destination);
+
+            if ($constraints_destination) {
+                $size = $constraints['rgt'] - $constraints['lft'] + 1;
 
-        $stmt = DBManager::get()->prepare("UPDATE forum_entries SET lft = lft + ?
+                $stmt = DBManager::get()->prepare("UPDATE forum_entries SET lft = lft + ?
             WHERE lft > ? AND seminar_id = ?");
-        $stmt->execute([$size, $constraints_destination['rgt'], $constraints_destination['seminar_id']]);
+                $stmt->execute([$size, $constraints_destination['rgt'], $constraints_destination['seminar_id']]);
 
-        $stmt = DBManager::get()->prepare("UPDATE forum_entries SET rgt = rgt + ?
+                $stmt = DBManager::get()->prepare("UPDATE forum_entries SET rgt = rgt + ?
             WHERE rgt >= ? AND seminar_id = ?");
-        $stmt->execute([$size, $constraints_destination['rgt'], $constraints_destination['seminar_id']]);
-
+                $stmt->execute([$size, $constraints_destination['rgt'], $constraints_destination['seminar_id']]);
+            }
+        }
         //move the entries from "outside" the tree to the target node
         $constraints_destination = ForumEntry::getConstraints($destination);
 
+        if ($constraints_destination) {
+            // update the depth to reflect the new position in the tree
+            // determine if we need to add, subtract or even do nothing to/from the depth
+            $depth_mod = $constraints_destination['depth'] - $constraints['depth'] + 1;
 
-        // update the depth to reflect the new position in the tree
-        // determine if we need to add, subtract or even do nothing to/from the depth
-        $depth_mod = $constraints_destination['depth'] - $constraints['depth'] + 1;
-
-        $stmt = DBManager::get()->prepare("UPDATE forum_entries
+            $stmt = DBManager::get()->prepare("UPDATE forum_entries
             SET depth = depth + ?
             WHERE seminar_id = ? AND lft < 0");
-        $stmt->execute([$depth_mod, $constraints_destination['seminar_id']]);
+            $stmt->execute([$depth_mod, $constraints_destination['seminar_id']]);
 
-        // if the depth is larger than 3, fix it
-        $stmt = DBManager::get()->prepare("UPDATE forum_entries
+            // if the depth is larger than 3, fix it
+            $stmt = DBManager::get()->prepare("UPDATE forum_entries
             SET depth = 3
             WHERE seminar_id = ? AND depth > 3 AND lft < 0");
-        $stmt->execute([$constraints_destination['seminar_id']]);
+            $stmt->execute([$constraints_destination['seminar_id']]);
 
-        // move the tree to its destination
-        $diff = ($constraints_destination['rgt'] - ($constraints['rgt'] - $constraints['lft'])) - 1 - $constraints['lft'];
+            // move the tree to its destination
+            $diff = ($constraints_destination['rgt'] - ($constraints['rgt'] - $constraints['lft'])) - 1 - $constraints['lft'];
 
-        $stmt = DBManager::get()->prepare("UPDATE forum_entries
+            $stmt = DBManager::get()->prepare("UPDATE forum_entries
             SET lft = (lft * -1) + ?, rgt = (rgt * -1) + ?
             WHERE seminar_id = ? AND lft < 0");
-        $stmt->execute([$diff, $diff, $constraints_destination['seminar_id']]);
+            $stmt->execute([$diff, $diff, $constraints_destination['seminar_id']]);
 
-        if ($depth_mod != 0) {
-            self::fix_ordering($topic_id);
+            if ($depth_mod != 0) {
+                self::fix_ordering($topic_id);
+            }
         }
     }
 
@@ -1119,11 +1168,14 @@ class ForumEntry  implements PrivacyObject
         $db = DBManager::get();
 
         $entry = ForumEntry::getConstraints($parent_id);
+        if (!$entry) {
+            return;
+        }
 
         $stmt= $db->prepare('SELECT topic_id FROM forum_entries
-                               WHERE lft > ? AND rgt < ? AND depth = 3
-                                    AND seminar_id = ?
-                               ORDER BY mkdate');
+                           WHERE lft > ? AND rgt < ? AND depth = 3
+                                AND seminar_id = ?
+                           ORDER BY mkdate');
 
         $stmt->execute([$entry['lft'], $entry['rgt'], $entry['seminar_id']]);
 
@@ -1131,7 +1183,7 @@ class ForumEntry  implements PrivacyObject
         $rgt = $lft + 1;
 
         $inner_stmt = $db->prepare("UPDATE forum_entries SET lft=?, rgt=?
-            WHERE topic_id = ?");
+        WHERE topic_id = ?");
         while ($topic_id = $stmt->fetchColumn()) {
             $inner_stmt->execute([$lft, $rgt, $topic_id]);
 
diff --git a/lib/classes/ForumLike.php b/lib/classes/ForumLike.php
index b964ceabae073733811902d4478d44d3a3c87513..fa0a4a8d2be1cd31c0bdc4c51f3b5d6ff4bb58de 100644
--- a/lib/classes/ForumLike.php
+++ b/lib/classes/ForumLike.php
@@ -20,7 +20,8 @@ class ForumLike {
      *
      * @param string $topic_id
      */
-    static function like($topic_id) {
+    public static function like($topic_id)
+    {
         $stmt = DBManager::get()->prepare("REPLACE INTO
             forum_likes (topic_id, user_id)
             VALUES (?, ?)");
@@ -28,10 +29,13 @@ class ForumLike {
 
         // get posting owner
         $data = ForumEntry::getConstraints($topic_id);
+        if (!$data) {
+            return;
+        }
 
         // notify owner of posting about the like
         setTempLanguage($data['user_id']);
-        $notification = get_fullname($GLOBALS['user']->id) . _(' gefällt einer deiner Forenbeiträge!');
+        $notification = $GLOBALS['user']->getFullName() . _(' gefällt einer deiner Forenbeiträge!');
         restoreLanguage();
 
         PersonalNotifications::add(
@@ -39,7 +43,7 @@ class ForumLike {
             URLHelper::getURL('dispatch.php/course/forum/index/index/' . $topic_id .'?highlight_topic='. $topic_id .'#'. $topic_id),
             $notification,
             $topic_id,
-            Icon::create('forum', 'clickable')
+            Icon::create('forum')
         );
     }
 
diff --git a/lib/classes/ForumPerm.php b/lib/classes/ForumPerm.php
index 24934dbc3d15185c4c7afe7943c44fcfe97d0913..28329789be9efa8e7709d980a03749c1adca87ca 100644
--- a/lib/classes/ForumPerm.php
+++ b/lib/classes/ForumPerm.php
@@ -158,7 +158,9 @@ class ForumPerm {
         if (empty($perms[$topic_id])) {
             // find out if the posting is the last in the thread
             $constraints = ForumEntry::getConstraints($topic_id);
-
+            if (!$constraints) {
+                return false;
+            }
             $stmt = DBManager::get()->prepare("SELECT user_id, seminar_id
                 FROM forum_entries WHERE topic_id = ?");
             $stmt->execute([$topic_id]);
@@ -205,7 +207,7 @@ class ForumPerm {
     {
         $data = ForumEntry::getConstraints($topic_id);
 
-        if ($data['seminar_id'] != $seminar_id) {
+        if (!$data || $data['seminar_id'] !== $seminar_id) {
             throw new AccessDeniedException(sprintf(
                 _('Forum: Sie haben keine Berechtigung auf den Eintrag mit der ID %s zuzugreifen!'),
                 $topic_id