Code Duplication    Length = 4-9 lines in 2 locations

main/forum/forumfunction.inc.php 2 locations

@@ 5752-5760 (lines=9) @@
5749
        $result = Database::query($sql);
5750
        if ($result !== false) {
5751
            $affectedRows = Database::affected_rows($result);
5752
            if ($affectedRows > 0) {
5753
                /*
5754
                 * If exist in $_SESSION variable, then delete them from it
5755
                 * because they would be deprecated
5756
                 */
5757
                if (!empty($_SESSION['forum']['upload_file'][$courseId][$id])) {
5758
                    unset($_SESSION['forum']['upload_file'][$courseId][$id]);
5759
                }
5760
            }
5761
5762
            return $affectedRows;
5763
        }
@@ 5970-5973 (lines=4) @@
5967
    }
5968
    if ($postId === -1) {
5969
        // If post ID is -1 then delete course's attachment data from $_SESSION
5970
        if (!empty($_SESSION['forum']['upload_file'][$courseId])) {
5971
            $array = array_keys($_SESSION['forum']['upload_file'][$courseId]);
5972
            unset($_SESSION['forum']['upload_file'][$courseId]);
5973
        }
5974
    } else {
5975
        $attachIds = getAttachmentIdsByPostId($postId, $courseId);
5976
        if (!empty($_SESSION['forum']['upload_file'][$courseId]) &&