]> git.mjollnir.org Git - moodle.git/commitdiff
get_complete_user_data(): speedup SQL selecting local users by their mnethostid
authormartinlanghoff <martinlanghoff>
Fri, 16 Mar 2007 03:37:52 +0000 (03:37 +0000)
committermartinlanghoff <martinlanghoff>
Fri, 16 Mar 2007 03:37:52 +0000 (03:37 +0000)
lib/moodlelib.php

index f0d8f7b31bc3d1d8708ee106137282e8712ad55d..0877dd8aa1ad96066e3895d071c2ff60e64c62b4 100644 (file)
@@ -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