diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 61db87c47ba..b02ddc0acf6 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -2753,70 +2753,13 @@ function message_get_contact() { } /** - * Returns list of courses, for whole site, or category - * - * Similar to get_courses, but allows paging - * Important: Using c.* for fields is extremely expensive because - * we are using distinct. You almost _NEVER_ need all the fields - * in such a large SELECT - * * @deprecated since Moodle 3.7 - * @todo The final deprecation of this function will take place in Moodle 3.11 - see MDL-65319. - * - * @param string|int $categoryid Either a category id or 'all' for everything - * @param string $sort A field and direction to sort by - * @param string $fields The additional fields to return - * @param int $totalcount Reference for the number of courses - * @param string $limitfrom The course to start from - * @param string $limitnum The number of courses to limit to - * @return array Array of courses */ -function get_courses_page($categoryid="all", $sort="c.sortorder ASC", $fields="c.*", - &$totalcount, $limitfrom="", $limitnum="") { - debugging('Function get_courses_page() is deprecated. Please use core_course_category::get_courses() ' . - 'or core_course_category::search_courses()', DEBUG_DEVELOPER); - global $USER, $CFG, $DB; - - $params = array(); - - $categoryselect = ""; - if ($categoryid !== "all" && is_numeric($categoryid)) { - $categoryselect = "WHERE c.category = :catid"; - $params['catid'] = $categoryid; - } else { - $categoryselect = ""; - } - - $ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); - $ccjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)"; - $params['contextlevel'] = CONTEXT_COURSE; - - $totalcount = 0; - if (!$limitfrom) { - $limitfrom = 0; - } - $visiblecourses = array(); - - $sql = "SELECT $fields $ccselect - FROM {course} c - $ccjoin - $categoryselect - ORDER BY $sort"; - - // Pull out all course matching the cat. - $rs = $DB->get_recordset_sql($sql, $params); - // Iteration will have to be done inside loop to keep track of the limitfrom and limitnum. - foreach ($rs as $course) { - context_helper::preload_from_record($course); - if (core_course_category::can_view_course_info($course)) { - $totalcount++; - if ($totalcount > $limitfrom && (!$limitnum or count($visiblecourses) < $limitnum)) { - $visiblecourses [$course->id] = $course; - } - } - } - $rs->close(); - return $visiblecourses; +function get_courses_page() { + throw new coding_exception( + 'Function get_courses_page() has been removed. Please use core_course_category::get_courses() ' . + 'or core_course_category::search_courses()' + ); } /** diff --git a/lib/upgrade.txt b/lib/upgrade.txt index d7d768c34fa..fb42ea9e0f4 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -4,6 +4,8 @@ information provided here is intended especially for developers. === 3.11 === * New optional parameter $extracontent for print_collapsible_region_start(). This allows developers to add interactive HTML elements (e.g. a help icon) after the collapsible region's toggle link. +* Final deprecation of get_courses_page. Function has been removed and core_course_category::get_courses() should be + used instead. === 3.10 === * PHPUnit has been upgraded to 8.5. That comes with a few changes: