Code Duplication    Length = 4-9 lines in 2 locations

main/forum/forumfunction.inc.php 2 locations

@@ 5754-5762 (lines=9) @@
5751
        $result = Database::query($sql);
5752
        if ($result !== false) {
5753
            $affectedRows = Database::affected_rows($result);
5754
            if ($affectedRows > 0) {
5755
                /*
5756
                 * If exist in $_SESSION variable, then delete them from it
5757
                 * because they would be deprecated
5758
                 */
5759
                if (!empty($_SESSION['forum']['upload_file'][$courseId][$id])) {
5760
                    unset($_SESSION['forum']['upload_file'][$courseId][$id]);
5761
                }
5762
            }
5763
5764
            return $affectedRows;
5765
        }
@@ 5945-5948 (lines=4) @@
5942
    }
5943
    if ($postId === -1) {
5944
        // If post ID is -1 then delete course's attachment data from $_SESSION
5945
        if (!empty($_SESSION['forum']['upload_file'][$courseId])) {
5946
            $array = array_keys($_SESSION['forum']['upload_file'][$courseId]);
5947
            unset($_SESSION['forum']['upload_file'][$courseId]);
5948
        }
5949
    } else {
5950
        $attachIds = getAttachmentIdsByPostId($postId, $courseId);
5951
        if (!empty($_SESSION['forum']['upload_file'][$courseId]) &&