Code Duplication    Length = 4-9 lines in 2 locations

main/forum/forumfunction.inc.php 2 locations

@@ 5770-5778 (lines=9) @@
5767
        $result = Database::query($sql);
5768
        if ($result !== false) {
5769
            $affectedRows = Database::affected_rows($result);
5770
            if ($affectedRows > 0) {
5771
                /*
5772
                 * If exist in $_SESSION variable, then delete them from it
5773
                 * because they would be deprecated
5774
                 */
5775
                if (!empty($_SESSION['forum']['upload_file'][$courseId][$id])) {
5776
                    unset($_SESSION['forum']['upload_file'][$courseId][$id]);
5777
                }
5778
            }
5779
5780
            return $affectedRows;
5781
        }
@@ 5961-5964 (lines=4) @@
5958
    }
5959
    if ($postId === -1) {
5960
        // If post ID is -1 then delete course's attachment data from $_SESSION
5961
        if (!empty($_SESSION['forum']['upload_file'][$courseId])) {
5962
            $array = array_keys($_SESSION['forum']['upload_file'][$courseId]);
5963
            unset($_SESSION['forum']['upload_file'][$courseId]);
5964
        }
5965
    } else {
5966
        $attachIds = getAttachmentIdsByPostId($postId, $courseId);
5967
        if (!empty($_SESSION['forum']['upload_file'][$courseId]) &&