Code Duplication    Length = 4-9 lines in 2 locations

main/forum/forumfunction.inc.php 2 locations

@@ 5825-5828 (lines=4) @@
5822
    }
5823
    if ($postId === -1) {
5824
        // If post ID is -1 then delete course's attachment data from $_SESSION
5825
        if (!empty($_SESSION['forum']['upload_file'][$courseId])) {
5826
            $array = array_keys($_SESSION['forum']['upload_file'][$courseId]);
5827
            unset($_SESSION['forum']['upload_file'][$courseId]);
5828
        }
5829
    } else {
5830
        $attachIds = getAttachmentIdsByPostId($postId, $courseId);
5831
        if (!empty($_SESSION['forum']['upload_file'][$courseId]) &&
@@ 5607-5615 (lines=9) @@
5604
        $result = Database::query($sql);
5605
        if ($result !== false) {
5606
            $affectedRows = Database::affected_rows($result);
5607
            if ($affectedRows > 0) {
5608
                /*
5609
                 * If exist in $_SESSION variable, then delete them from it
5610
                 * because they would be deprecated
5611
                 */
5612
                if (!empty($_SESSION['forum']['upload_file'][$courseId][$id])) {
5613
                    unset($_SESSION['forum']['upload_file'][$courseId][$id]);
5614
                }
5615
            }
5616
5617
            return $affectedRows;
5618
        }