Code Duplication    Length = 4-9 lines in 2 locations

main/forum/forumfunction.inc.php 2 locations

@@ 5590-5598 (lines=9) @@
5587
        $result = Database::query($sql);
5588
        if ($result !== false) {
5589
            $affectedRows = Database::affected_rows($result);
5590
            if ($affectedRows > 0) {
5591
                /*
5592
                 * If exist in $_SESSION variable, then delete them from it
5593
                 * because they would be deprecated
5594
                 */
5595
                if (!empty($_SESSION['forum']['upload_file'][$courseId][$id])) {
5596
                    unset($_SESSION['forum']['upload_file'][$courseId][$id]);
5597
                }
5598
            }
5599
5600
            return $affectedRows;
5601
        }
@@ 5808-5811 (lines=4) @@
5805
    }
5806
    if ($postId === -1) {
5807
        // If post ID is -1 then delete course's attachment data from $_SESSION
5808
        if (!empty($_SESSION['forum']['upload_file'][$courseId])) {
5809
            $array = array_keys($_SESSION['forum']['upload_file'][$courseId]);
5810
            unset($_SESSION['forum']['upload_file'][$courseId]);
5811
        }
5812
    } else {
5813
        $attachIds = getAttachmentIdsByPostId($postId, $courseId);
5814
        if (!empty($_SESSION['forum']['upload_file'][$courseId]) &&