From 33905692957eb1cce0451a52ef9a6e8061c7dd83 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 18 Nov 2008 14:59:16 +0000 Subject: - Patch #334671 by Steve Dondley: users cannot be assigned to roles or removed from them -- comes with tests. Yay. --- modules/user/user.module | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) (limited to 'modules/user/user.module') diff --git a/modules/user/user.module b/modules/user/user.module index f1a8593b7..50bf43fdd 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -139,9 +139,6 @@ function user_external_login($account, $edit = array()) { * An associative array of attributes to search for in selecting the * user, such as user name or e-mail address. * - * @return - * A fully-loaded $user object upon successful user load or FALSE if user - * cannot be loaded. */ function user_load($array = array()) { // Dynamically compose a SQL query: @@ -212,7 +209,7 @@ function user_load($array = array()) { * (optional) The category for storing profile information in. * * @return - * A fully-loaded $user object upon successful save or FALSE if the save failed. + * A fully-loaded $user object. */ function user_save($account, $edit = array(), $category = 'account') { $table = drupal_get_schema('users'); @@ -256,11 +253,7 @@ function user_save($account, $edit = array(), $category = 'account') { $edit['data'] = $data; $edit['uid'] = $account->uid; // Save changes to the users table. - $success = drupal_write_record('users', $edit, 'uid'); - if (!$success) { - // The query failed - better to abort the save than risk further data loss. - return FALSE; - } + drupal_write_record('users', $edit, 'uid'); // Reload user roles if provided. if (isset($edit['roles']) && is_array($edit['roles'])) { @@ -308,12 +301,7 @@ function user_save($account, $edit = array(), $category = 'account') { $edit['access'] = REQUEST_TIME; } - $success = drupal_write_record('users', $edit); - if (!$success) { - // On a failed INSERT some other existing user's uid may be returned. - // We must abort to avoid overwriting their account. - return FALSE; - } + drupal_write_record('users', $edit); // Build the initial user object. $user = user_load(array('uid' => $edit['uid'])); @@ -1413,11 +1401,6 @@ function user_external_login_register($name, $module) { 'access' => REQUEST_TIME ); $account = user_save('', $userinfo); - // Terminate if an error occured during user_save(). - if (!$account) { - drupal_set_message(t("Error saving user account."), 'error'); - return; - } user_set_authmaps($account, array("authname_$module" => $name)); $user = $account; watchdog('user', 'New external user: %name using module %module.', array('%name' => $name, '%module' => $module), WATCHDOG_NOTICE, l(t('edit'), 'user/' . $user->uid . '/edit')); @@ -2287,12 +2270,6 @@ function user_register_submit($form, &$form_state) { $merge_data['status'] = variable_get('user_register', 1) == 1; } $account = user_save('', array_merge($form_state['values'], $merge_data)); - // Terminate if an error occured during user_save(). - if (!$account) { - drupal_set_message(t("Error saving user account."), 'error'); - $form_state['redirect'] = ''; - return; - } $form_state['user'] = $account; watchdog('user', 'New user: %name (%email).', array('%name' => $name, '%email' => $mail), WATCHDOG_NOTICE, l(t('edit'), 'user/' . $account->uid . '/edit')); -- cgit v1.2.3