Just reported this to Moodle bug tracker (tracker.moodle.org):
First here are two links as a quick FYI:
http://lupus.omrf.org/~kilpatjr/not_in_wrong_results.perl
http://bugs.mysql.com/bug.php?id=21282
This is a reported bug in MySQL.
In Moodle 1.5.x /course/student.php it uses get_users (which was from /lib/datalib.php), this function use "NOT IN" for the "if ($exceptions)" and this would create an issue when you have more than 1000 students in your class, as then when you access the student.php it will display wrong student numbers and so on. Here is a fix we found:
at around #128 of student.php (1.5.x)
// MySQL has difficulty with NOT IN lists that are > 1000; So since we use MySQL 5 now, I've removed the lines that create
// a list of all the user ids and replaced it with a subquery that we pass to get_users. - CT 2/2/07
//$existinguserarray = array();
//foreach ($students as $student) {
// $existinguserarray[] = $student->id;
//}
//foreach ($teachers as $teacher) {
// $existinguserarray[] = $teacher->id;
//}
//$existinguserlist = implode(',', $existinguserarray);
//unset($existinguserarray);
$existinguserquery = "SELECT userid FROM {$CFG->prefix}user_students WHERE course=$course->id UNION SELECT userid FROM {$CFG->prefix}user_teachers WHERE course=$course->id";
/// Get search results excluding any users already in this course
if (!empty($frm->searchtext) and $previoussearch) {
$searchusers = get_users(true, $frm->searchtext, true, $existinguserquery, 'firstname ASC, lastname ASC',
'', '', 0, 99999, 'id, firstname, lastname, email');
$usercount = get_users(false, '', true, $existinguserquery);
}
/// If no search results then get potential students for this course excluding users already in course
if (empty($searchusers)) {
$usercount = get_users(false, '', true, $existinguserquery, 'firstname ASC, lastname ASC', '', '',
0, 99999, 'id, firstname, lastname, email') ;
$users = array();
if ($usercount <= MAX_USERS_PER_PAGE) {
$users = get_users(true, '', true, $existinguserquery, 'firstname ASC, lastname ASC', '', '',
0, 99999, 'id, firstname, lastname, email');
}
}
We have tested this fix and it seems to work OK but certainly could use some more testing here in moodle community.
Again I believe this is still an issue in both 1.7 and 1.8 as both are still using the same get_users() function, we have not yet tested this issue on 1.7 and 1.8 but I think this has not been fixed in 1.7 and 1.8 with MySQL 5.x. Bug fix was contributed by our staff programmer Cliff Tham.
Testing and QA
The get_users function in lib/datalib.php use "NOT IN" which has trouble with MySQL 5.x (MDL-8549)
Այս քննարկումը արգելափակված է: Դուք այլևս չեք կարող պատասխանել դրան: