diff --git a/public/main/inc/lib/course.lib.php b/public/main/inc/lib/course.lib.php index 18c9d578a9..6c867e27fa 100644 --- a/public/main/inc/lib/course.lib.php +++ b/public/main/inc/lib/course.lib.php @@ -2571,7 +2571,7 @@ class CourseManager $groupCategories = GroupManager::get_categories($course['code']); if (!empty($groupCategories)) { foreach ($groupCategories as $category) { - GroupManager::delete_category($category['id'], $course['code']); + GroupManager::delete_category($category['iid'], $course['code']); } } diff --git a/public/main/inc/lib/groupmanager.lib.php b/public/main/inc/lib/groupmanager.lib.php index 6df81bf70c..7029c6dc75 100644 --- a/public/main/inc/lib/groupmanager.lib.php +++ b/public/main/inc/lib/groupmanager.lib.php @@ -906,7 +906,7 @@ class GroupManager $table_group = Database::get_course_table(TABLE_GROUP); $table_group_cat = Database::get_course_table(TABLE_GROUP_CATEGORY); - $cat_id = intval($cat_id); + $cat_id = (int) $cat_id; $sql = "SELECT iid FROM $table_group WHERE c_id = $course_id AND category_id='".$cat_id."'"; $res = Database::query($sql); @@ -922,7 +922,7 @@ class GroupManager } } $sql = "DELETE FROM $table_group_cat - WHERE c_id = $course_id AND id='".$cat_id."'"; + WHERE c_id = $course_id AND iid='".$cat_id."'"; Database::query($sql); return true; diff --git a/src/CoreBundle/EventListener/CourseListener.php b/src/CoreBundle/EventListener/CourseListener.php index 823662704c..1126fcc811 100644 --- a/src/CoreBundle/EventListener/CourseListener.php +++ b/src/CoreBundle/EventListener/CourseListener.php @@ -84,6 +84,10 @@ class CourseListener $em = $container->get('doctrine')->getManager(); $course = $em->getRepository(Course::class)->find($courseId); + if (null === $course) { + throw new NotFoundHttpException($translator->trans('Course does not exist')); + } + //dump("Course loaded from DB $courseId"); $courseInfo = api_get_course_info($course->getCode()); }