mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
get_complete_user_data(): speedup SQL selecting local users by their mnethostid
This commit is contained in:
parent
fae83c8d32
commit
e5edab1b72
1 changed files with 10 additions and 8 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue