From e5edab1b7212026f798e2f283509b818951f8be7 Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Fri, 16 Mar 2007 03:37:52 +0000 Subject: [PATCH] get_complete_user_data(): speedup SQL selecting local users by their mnethostid --- lib/moodlelib.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index f0d8f7b31b..0877dd8aa1 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2782,15 +2782,17 @@ function get_complete_user_data($field, $value, $mnethostid=null) { $constraints = $field .' = \''. $value .'\' AND deleted <> \'1\''; - if (null === $mnethostid) { - $constraints .= ' AND auth != \'mnet\''; - } elseif (is_numeric($mnethostid)) { - $constraints .= ' AND mnethostid = \''.$mnethostid.'\''; - } else { - error_log('Call to get_complete_user_data for $field='.$field.', $value = '.$value.', with invalid $mnethostid: '. $mnethostid); - print_error('invalidhostlogin','mnet', $CFG->wwwroot.'/login/index.php'); - exit; - } + if (is_null($mnethostid)) { + // if null, we restrict to local users + // ** testing for local user can be done with + // mnethostid = $CFG->mnet_localhost_id + // or with + // auth != 'mnet' + // but the first one is FAST with our indexes + $mnethostid = $CFG->mnet_localhost_id; + } + $mnethostid = (int)$mnethostid; + $constraints .= ' AND mnethostid = \''.$mnethostid.'\''; /// Get all the basic user data -- 2.39.5