MDL-16061 Revert incorrect fix for "Remove 'username' from the $moodleattributes array"
The fix is wrong, as it breaks auth_db_sync_users.php and auth_ldap_sync_users.php at least. No new users are added to Moodle, as the username is missing from the new user info record. The fix needs to go into update_user_record() in lib/moodlelib.php to make it skip the 'username' key, as we really need get_userinfo() to return the username as part of the user info array.
This commit is contained in:
+2
-1
@@ -495,6 +495,7 @@ if ( !is_object($PHPCAS_CLIENT) ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
$moodleattributes['username'] = $this->config->user_attribute;
|
||||
return $moodleattributes;
|
||||
}
|
||||
/**
|
||||
@@ -1122,4 +1123,4 @@ if (!empty($this->config->attrcreators)) {
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -135,6 +135,7 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
$moodleattributes[$field] = $this->config->{"field_map_$field"};
|
||||
}
|
||||
}
|
||||
$moodleattributes['username'] = $this->config->fielduser;
|
||||
return $moodleattributes;
|
||||
}
|
||||
|
||||
|
||||
@@ -1489,6 +1489,7 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||
}
|
||||
}
|
||||
}
|
||||
$moodleattributes['username'] = $this->config->user_attribute;
|
||||
return $moodleattributes;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,6 +129,7 @@ class auth_plugin_shibboleth extends auth_plugin_base {
|
||||
$moodleattributes[$field] = $configarray["field_map_$field"];
|
||||
}
|
||||
}
|
||||
$moodleattributes['username'] = $configarray["user_attribute"];
|
||||
|
||||
return $moodleattributes;
|
||||
}
|
||||
|
||||
@@ -2605,6 +2605,10 @@ function update_user_record($username, $authplugin) {
|
||||
if ($newinfo = $userauth->get_userinfo($username)) {
|
||||
$newinfo = truncate_userinfo($newinfo);
|
||||
foreach ($newinfo as $key => $value){
|
||||
if ($key === 'username') {
|
||||
// 'username' is not a mapped updateable/lockable field, so skip it.
|
||||
continue;
|
||||
}
|
||||
$confval = $userauth->config->{'field_updatelocal_' . $key};
|
||||
$lockval = $userauth->config->{'field_lock_' . $key};
|
||||
if (empty($confval) || empty($lockval)) {
|
||||
|
||||
Reference in New Issue
Block a user