Code Duplication    Length = 4-9 lines in 2 locations

main/forum/forumfunction.inc.php 2 locations

@@ 5635-5643 (lines=9) @@
5632
        $result = Database::query($sql);
5633
        if ($result !== false) {
5634
            $affectedRows = Database::affected_rows($result);
5635
            if ($affectedRows > 0) {
5636
                /*
5637
                 * If exist in $_SESSION variable, then delete them from it
5638
                 * because they would be deprecated
5639
                 */
5640
                if (!empty($_SESSION['forum']['upload_file'][$courseId][$id])) {
5641
                    unset($_SESSION['forum']['upload_file'][$courseId][$id]);
5642
                }
5643
            }
5644
5645
            return $affectedRows;
5646
        }
@@ 5826-5829 (lines=4) @@
5823
    }
5824
    if ($postId === -1) {
5825
        // If post ID is -1 then delete course's attachment data from $_SESSION
5826
        if (!empty($_SESSION['forum']['upload_file'][$courseId])) {
5827
            $array = array_keys($_SESSION['forum']['upload_file'][$courseId]);
5828
            unset($_SESSION['forum']['upload_file'][$courseId]);
5829
        }
5830
    } else {
5831
        $attachIds = getAttachmentIdsByPostId($postId, $courseId);
5832
        if (!empty($_SESSION['forum']['upload_file'][$courseId]) &&