Index: modules/user/user.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.api.php,v
retrieving revision 1.20
diff -u -p -r1.20 user.api.php
--- modules/user/user.api.php	9 Feb 2010 22:30:30 -0000	1.20
+++ modules/user/user.api.php	4 Mar 2010 04:53:29 -0000
@@ -200,10 +200,8 @@ function hook_user_categories() {
  *
  * This hook is primarily intended for modules that want to store properties in
  * the serialized {users}.data column, which is automatically loaded whenever a
- * user account object is loaded, and the module needs to prepare the stored
- * data in some way.
- * The module should save its custom additions to the user object into the
- * database and set the saved fields to NULL in $edit.
+ * user account object is loaded, modules may add to $edit['data'] in order
+ * to have their data serialized on save.
  *
  * @param &$edit
  *   The array of form values submitted by the user.
@@ -218,9 +216,7 @@ function hook_user_categories() {
 function hook_user_presave(&$edit, $account, $category) {
   // Make sure that our form value 'mymodule_foo' is stored as 'mymodule_bar'.
   if (isset($edit['mymodule_foo'])) {
-    $edit['mymodule_bar'] = $edit['mymodule_foo'];
-    // Inform user_save() to ignore the value of our property.
-    $edit['mymodule_foo'] = NULL;
+    $edit['data']['my_module_foo'] = $edit['my_module_foo'];
   }
 }
 
@@ -228,7 +224,7 @@ function hook_user_presave(&$edit, $acco
  * A user account was created.
  *
  * The module should save its custom additions to the user object into the
- * database and set the saved fields to NULL in $edit.
+ * database.
  *
  * @param &$edit
  *   The array of form values submitted by the user.
@@ -247,8 +243,6 @@ function hook_user_insert(&$edit, $accou
       'uid' => $account->uid,
     ))
     ->execute();
-  // Inform user_save() to ignore the value of our property.
-  $edit['myfield'] = NULL;
 }
 
 /**
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.1131
diff -u -p -r1.1131 user.module
--- modules/user/user.module	2 Mar 2010 09:12:31 -0000	1.1131
+++ modules/user/user.module	4 Mar 2010 04:53:30 -0000
@@ -344,7 +344,6 @@ function user_save($account, $edit = arr
   $transaction = db_transaction();
   try {
     $table = drupal_get_schema('users');
-    $user_fields = $table['fields'];
 
     if (!empty($edit['pass'])) {
       // Allow alternate password hashing schemes.
@@ -372,33 +371,11 @@ function user_save($account, $edit = arr
     user_module_invoke('presave', $edit, $account, $category);
 
     if (is_object($account) && !$account->is_new) {
-      $data = unserialize(db_query('SELECT data FROM {users} WHERE uid = :uid', array(':uid' => $account->uid))->fetchField());
       // Consider users edited by an administrator as logged in, if they haven't
       // already, so anonymous users can view the profile (if allowed).
       if (empty($edit['access']) && empty($account->access) && user_access('administer users')) {
         $edit['access'] = REQUEST_TIME;
       }
-      // Find the fields attached to this user.
-      $field_names = array();
-      list(, , $bundle) = entity_extract_ids('user', (object) $edit);
-      foreach (field_info_instances('user', $bundle) as $instance) {
-        $field = field_info_field_by_id($instance['field_id']);
-        $field_names[] = $field['field_name'];
-      }
-
-      foreach ($edit as $key => $value) {
-        // Form fields that don't pertain to the users, user_roles, or
-        // Field API are automatically serialized into the users.data
-        // column.
-        if (!in_array($key, array('roles', 'is_new')) && empty($user_fields[$key]) && empty($field_names[$key])) {
-          if ($value === NULL) {
-            unset($data[$key]);
-          }
-          else {
-            $data[$key] = $value;
-          }
-        }
-      }
 
       // Process picture uploads.
       if (!empty($edit['picture']->fid)) {
@@ -421,7 +398,6 @@ function user_save($account, $edit = arr
       }
       $edit['picture'] = empty($edit['picture']->fid) ? 0 : $edit['picture']->fid;
 
-      $edit['data'] = $data;
       // Do not allow 'uid' to be changed.
       $edit['uid'] = $account->uid;
       // Save changes to the user table.
@@ -521,22 +497,6 @@ function user_save($account, $edit = arr
       user_module_invoke('insert', $edit, $user, $category);
       entity_invoke('insert', 'user', $user);
 
-      // Note, we wait with saving the data column to prevent module-handled
-      // fields from being saved there.
-      $data = array();
-      foreach ($edit as $key => $value) {
-        // Form fields that don't pertain to the users, user_roles, or
-        // Field API are automatically serialized into the user.data
-        // column.
-        if ((!in_array($key, array('roles', 'is_new'))) && (empty($user_fields[$key]) && empty($field_form[$key])) && ($value !== NULL)) {
-          $data[$key] = $value;
-        }
-      }
-      if (!empty($data)) {
-        $data_array = array('uid' => $user->uid, 'data' => $data);
-        drupal_write_record('users', $data_array, 'uid');
-      }
-
       // Save user roles (delete just to be safe).
       if (isset($edit['roles']) && is_array($edit['roles'])) {
         db_delete('users_roles')
@@ -1158,10 +1118,6 @@ function user_user_presave(&$edit, $acco
     elseif (!empty($edit['picture_delete'])) {
       $edit['picture'] = NULL;
     }
-    // Remove these values so they don't end up serialized in the data field.
-    $edit['picture_upload'] = NULL;
-    $edit['picture_delete'] = NULL;
-
     // Prepare user roles.
     if (isset($edit['roles'])) {
       $edit['roles'] = array_filter($edit['roles']);
Index: modules/user/user.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.pages.inc,v
retrieving revision 1.68
diff -u -p -r1.68 user.pages.inc
--- modules/user/user.pages.inc	28 Feb 2010 20:10:34 -0000	1.68
+++ modules/user/user.pages.inc	4 Mar 2010 04:53:30 -0000
@@ -287,8 +287,6 @@ function user_profile_form_validate($for
 function user_profile_form_submit($form, &$form_state) {
   $account = $form['#user'];
   $category = $form['#user_category'];
-  // Remove unneeded values.
-  form_state_values_clean($form_state);
 
   $edit = (object)$form_state['values'];
   field_attach_submit('user', $edit, $form, $form_state);
