Code Duplication    Length = 4-9 lines in 2 locations

main/forum/forumfunction.inc.php 2 locations

@@ 5659-5667 (lines=9) @@
5656
        $result = Database::query($sql);
5657
        if ($result !== false) {
5658
            $affectedRows = Database::affected_rows($result);
5659
            if ($affectedRows > 0) {
5660
                /*
5661
                 * If exist in $_SESSION variable, then delete them from it
5662
                 * because they would be deprecated
5663
                 */
5664
                if (!empty($_SESSION['forum']['upload_file'][$courseId][$id])) {
5665
                    unset($_SESSION['forum']['upload_file'][$courseId][$id]);
5666
                }
5667
            }
5668
5669
            return $affectedRows;
5670
        }
@@ 5850-5853 (lines=4) @@
5847
    }
5848
    if ($postId === -1) {
5849
        // If post ID is -1 then delete course's attachment data from $_SESSION
5850
        if (!empty($_SESSION['forum']['upload_file'][$courseId])) {
5851
            $array = array_keys($_SESSION['forum']['upload_file'][$courseId]);
5852
            unset($_SESSION['forum']['upload_file'][$courseId]);
5853
        }
5854
    } else {
5855
        $attachIds = getAttachmentIdsByPostId($postId, $courseId);
5856
        if (!empty($_SESSION['forum']['upload_file'][$courseId]) &&