Permalink
Browse files

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

…mnethostid
  • Loading branch information...
1 parent e217284 commit d15c13904e2b80260328e2c531074b48fb334229 martinlanghoff committed Mar 16, 2007
Showing with 11 additions and 9 deletions.
  1. +11 −9 lib/moodlelib.php
View
@@ -2760,15 +2760,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

0 comments on commit d15c139

Please sign in to comment.