From: iarenaza Date: Mon, 25 Aug 2008 22:44:45 +0000 (+0000) Subject: MDL-16061 Revert incorrect fix for "Remove 'username' from the $moodleattributes... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=5261baf11e13e0b7bf02272b39a9ff29989df423;p=moodle.git MDL-16061 Revert incorrect fix for "Remove 'username' from the $moodleattributes array" Merged from MOODLE_18_STABLE. 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. --- diff --git a/auth/cas/auth.php b/auth/cas/auth.php index 8e137eb1a4..fb42870df0 100644 --- a/auth/cas/auth.php +++ b/auth/cas/auth.php @@ -500,6 +500,7 @@ if ( !is_object($PHPCAS_CLIENT) ) { } } } + $moodleattributes['username'] = $this->config->user_attribute; return $moodleattributes; } /** diff --git a/auth/db/auth.php b/auth/db/auth.php index ba3cf7529f..c0f57aff6f 100644 --- a/auth/db/auth.php +++ b/auth/db/auth.php @@ -137,6 +137,7 @@ class auth_plugin_db extends auth_plugin_base { $moodleattributes[$field] = $this->config->{"field_map_$field"}; } } + $moodleattributes['username'] = $this->config->fielduser; return $moodleattributes; } diff --git a/auth/ldap/auth.php b/auth/ldap/auth.php index e3902a72d5..d7eeea7e49 100644 --- a/auth/ldap/auth.php +++ b/auth/ldap/auth.php @@ -1637,6 +1637,7 @@ class auth_plugin_ldap extends auth_plugin_base { } } } + $moodleattributes['username'] = $this->config->user_attribute; return $moodleattributes; } diff --git a/auth/shibboleth/auth.php b/auth/shibboleth/auth.php index 84309c28a9..8ed938150f 100644 --- a/auth/shibboleth/auth.php +++ b/auth/shibboleth/auth.php @@ -128,6 +128,7 @@ class auth_plugin_shibboleth extends auth_plugin_base { $moodleattributes[$field] = $configarray["field_map_$field"]; } } + $moodleattributes['username'] = $configarray["user_attribute"]; return $moodleattributes; } diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 14ba40c773..b8ac39df34 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2831,6 +2831,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)) {