Skip to content
Permalink
Browse files

MDL-57193 auth_db: Use a recordset and array_key_exists

  • Loading branch information
John Okely authored and FMCorz committed Dec 2, 2016
1 parent 4f22f01 commit fdaea8ad644bf835a3225f4bdf64ecc6ba36aeb7
Showing with 6 additions and 3 deletions.
  1. +6 −3 auth/db/auth.php
@@ -308,12 +308,15 @@ function sync_users(progress_trace $trace, $do_updates=false) {
FROM {user} u
WHERE u.auth=:authtype AND u.deleted=0 AND u.mnethostid=:mnethostid $suspendselect";
$params['mnethostid'] = $CFG->mnet_localhost_id;
$internalusers = $DB->get_records_sql($sql, $params);
foreach ($internalusers as $internaluser) {
if (!in_array($internaluser->username, $userlist)) {
$internalusersrs = $DB->get_recordset_sql($sql, $params);
foreach ($internalusersrs as $internaluser) {
// Arrange the associative array.
$usernamelist = array_flip($userlist);
if (!array_key_exists($internaluser->username, $usernamelist)) {
$removeusers[] = $internaluser;
}
}
$internalusersrs->close();
} else {
$sql = "SELECT u.id, u.username
FROM {user} u

0 comments on commit fdaea8a

Please sign in to comment.
You can’t perform that action at this time.