From fb549063df7b110e75ef7a6dc1ffbe6bb98ad993 Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Wed, 22 Dec 2004 21:59:13 +0000 Subject: [PATCH] Fixed upgrade bug that could show up in cases where: - installations with large numbers of courses in a category AND 'hidden' courses in those categories - where the database upgrade was performed while NOT in a logged-in-admin session fix_course_sortorder() would fail to guarantee the uniqueness of course,sortorder and the new unique index on that column would fail to be created. Sigh. --- lib/datalib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/datalib.php b/lib/datalib.php index c6e970abe8f..ce4f1e1c582 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -2092,7 +2092,7 @@ function fix_course_sortorder($categoryid=0, $n=0, $safe=0) { if ($count && ( $safe || ($max-$min+1!=$count) || $min < 10 ) ) { - if ($courses = get_courses($categoryid, 'c.sortorder ASC', 'c.id,c.sortorder')) { + if ($courses = get_records_sql("SELECT c.id, c.sortorder FROM {$CFG->prefix}course c WHERE category=$categoryid ORDER BY c.sortorder ASC")) { begin_sql(); // find the ideal starting point