Merge branch 'm20_MDL-25669_course_sortorder' of git://github.com/dongsheng/moodle

This commit is contained in:
Petr Skoda
2011-01-10 14:51:22 +01:00
+9
View File
@@ -1039,11 +1039,20 @@ function fix_course_sortorder() {
HAVING cc.coursecount <> COUNT(c.id)";
if ($updatecounts = $DB->get_records_sql($sql)) {
// categories with more courses than MAX_COURSES_IN_CATEGORY
$categories = array();
foreach ($updatecounts as $cat) {
$cat->coursecount = $cat->newcount;
if ($cat->coursecount >= MAX_COURSES_IN_CATEGORY) {
$categories[] = $cat->id;
}
unset($cat->newcount);
$DB->update_record_raw('course_categories', $cat, true);
}
if (!empty($categories)) {
$str = implode(', ', $categories);
debugging("The number of courses (category id: $str) has reached MAX_COURSES_IN_CATEGORY (" . MAX_COURSES_IN_CATEGORY . "), it will cause a sorting performance issue, please increase the value of MAX_COURSES_IN_CATEGORY in lib/datalib.php file. See tracker issue: MDL-25669", DEBUG_DEVELOPER);
}
}
// now make sure that sortorders in course table are withing the category sortorder ranges