get_complete_user_data(): speedup SQL selecting local users by their mnethostid

This commit is contained in:
martinlanghoff 2007-03-16 03:37:52 +00:00
parent fae83c8d32
commit e5edab1b72

View file

@ -2782,15 +2782,17 @@ function get_complete_user_data($field, $value, $mnethostid=null) {
$constraints = $field .' = \''. $value .'\' AND deleted <> \'1\''; $constraints = $field .' = \''. $value .'\' AND deleted <> \'1\'';
if (null === $mnethostid) { if (is_null($mnethostid)) {
$constraints .= ' AND auth != \'mnet\''; // if null, we restrict to local users
} elseif (is_numeric($mnethostid)) { // ** testing for local user can be done with
$constraints .= ' AND mnethostid = \''.$mnethostid.'\''; // mnethostid = $CFG->mnet_localhost_id
} else { // or with
error_log('Call to get_complete_user_data for $field='.$field.', $value = '.$value.', with invalid $mnethostid: '. $mnethostid); // auth != 'mnet'
print_error('invalidhostlogin','mnet', $CFG->wwwroot.'/login/index.php'); // but the first one is FAST with our indexes
exit; $mnethostid = $CFG->mnet_localhost_id;
} }
$mnethostid = (int)$mnethostid;
$constraints .= ' AND mnethostid = \''.$mnethostid.'\'';
/// Get all the basic user data /// Get all the basic user data