From c99f31c86b4bca9fccf709cc11327bf3286d78ea Mon Sep 17 00:00:00 2001 From: iarenaza Date: Mon, 25 Aug 2008 22:35:26 +0000 Subject: [PATCH] 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. --- auth/cas/auth.php | 3 ++- auth/db/auth.php | 1 + auth/ldap/auth.php | 1 + auth/shibboleth/auth.php | 1 + lib/moodlelib.php | 4 ++++ 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/auth/cas/auth.php b/auth/cas/auth.php index 04f7cc0df1c..f94d1664894 100644 --- a/auth/cas/auth.php +++ b/auth/cas/auth.php @@ -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; } } -?> \ No newline at end of file +?> diff --git a/auth/db/auth.php b/auth/db/auth.php index 9820dfe1501..19523fa5df5 100644 --- a/auth/db/auth.php +++ b/auth/db/auth.php @@ -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; } diff --git a/auth/ldap/auth.php b/auth/ldap/auth.php index bbc747f1c28..5df01079c91 100644 --- a/auth/ldap/auth.php +++ b/auth/ldap/auth.php @@ -1489,6 +1489,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 f7d976fb227..287b5c4dc58 100644 --- a/auth/shibboleth/auth.php +++ b/auth/shibboleth/auth.php @@ -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; } diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 8f3c47173d8..f3a18642683 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -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)) {