? files
? mw.patch
? phpinfo.php
? tmp.patch
? sites/all/modules
? sites/all/themes
? sites/default/mw.patch
? sites/default/tmp.patch
Index: modules/profile/profile.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.module,v
retrieving revision 1.220
diff -u -F^f -r1.220 profile.module
--- modules/profile/profile.module	5 Oct 2007 13:26:53 -0000	1.220
+++ modules/profile/profile.module	7 Oct 2007 13:17:09 -0000
@@ -344,7 +344,8 @@ function profile_field_form_validate($fo
     form_set_error('name', t('The specified form name contains one or more illegal characters. Spaces or any other special characters except dash (-) and underscore (_) are not allowed.'));
   }
 
-  if (in_array($form_state['values']['name'], user_fields())) {
+  $user_fields = drupal_get_schema('users');
+  if (in_array($form_state['values']['name'], array_keys($user_fields['fields']))) {
     form_set_error('name', t('The specified form name is reserved for use by Drupal.'));
   }
   // Validate the category:
Index: modules/user/user.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.install,v
retrieving revision 1.1
diff -u -F^f -r1.1 user.install
--- modules/user/user.install	5 Oct 2007 16:07:22 -0000	1.1
+++ modules/user/user.install	7 Oct 2007 13:17:09 -0000
@@ -65,7 +65,7 @@ function user_schema() {
       'language'  => array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''),
       'picture'   => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
       'init'      => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE, 'default' => ''),
-      'data'      => array('type' => 'text', 'not null' => FALSE, 'size' => 'big')
+      'data'      => array('type' => 'text', 'not null' => FALSE, 'size' => 'big', 'serialize' => TRUE)
     ),
     'indexes' => array(
       'access'  => array('access'),
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.851
diff -u -F^f -r1.851 user.module
--- modules/user/user.module	3 Oct 2007 13:01:04 -0000	1.851
+++ modules/user/user.module	7 Oct 2007 13:17:10 -0000
@@ -197,22 +197,24 @@ function user_load($array = array()) {
  *   (optional) The category for storing profile information in.
  */
 function user_save($account, $array = array(), $category = 'account') {
-  // Dynamically compose a SQL query:
-  $user_fields = user_fields();
+  $fields = drupal_get_schema('users');
+  $user_fields = array_keys($fields['fields']);
+
+  if (!empty($array['pass'])) {
+    $array['pass'] = md5($array['pass']);
+  }
+  else {
+    // Avoid overwriting an existing password with a blank password.
+    unset($array['pass']);
+  }
+  
   if (is_object($account) && $account->uid) {
     user_module_invoke('update', $array, $account, $category);
-    $query = '';
     $data = unserialize(db_result(db_query('SELECT data FROM {users} WHERE uid = %d', $account->uid)));
     foreach ($array as $key => $value) {
-      if ($key == 'pass' && !empty($value)) {
-        $query .= "$key = '%s', ";
-        $v[] = md5($value);
-      }
-      else if ((substr($key, 0, 4) !== 'auth') && ($key != 'pass')) {
+      if ((substr($key, 0, 4) !== 'auth')) {
         if (in_array($key, $user_fields)) {
-          // Save standard fields
-          $query .= "$key = '%s', ";
-          $v[] = $value;
+          // do nothing
         }
         else if ($key != 'roles') {
           // Roles is a special case: it used below.
@@ -225,10 +227,12 @@ function user_save($account, $array = ar
         }
       }
     }
-    $query .= "data = '%s' ";
-    $v[] = serialize($data);
+    if (!empty($data)) {
+      $array['data'] = $data;
+    }
+    $array['uid'] = $account->uid;
 
-    db_query("UPDATE {users} SET $query WHERE uid = %d", array_merge($v, array($account->uid)));
+    drupal_write_record('users', $array, 'uid');
 
     // Reload user roles if provided
     if (isset($array['roles']) && is_array($array['roles'])) {
@@ -270,48 +274,25 @@ function user_save($account, $array = ar
       $array['created'] = time();
     }
 
-    // Note, we wait with saving the data column to prevent module-handled
-    // fields from being saved there. We cannot invoke hook_user('insert') here
-    // because we don't have a fully initialized user object yet.
-    foreach ($array as $key => $value) {
-      switch ($key) {
-        case 'pass':
-          $fields[] = $key;
-          $values[] = md5($value);
-          $s[] = "'%s'";
-          break;
-        case 'mode':       case 'sort':     case 'timezone':
-        case 'threshold':  case 'created':  case 'access':
-        case 'login':      case 'status':
-          $fields[] = $key;
-          $values[] = $value;
-          $s[] = "%d";
-          break;
-        default:
-          if (substr($key, 0, 4) !== 'auth' && in_array($key, $user_fields)) {
-            $fields[] = $key;
-            $values[] = $value;
-            $s[] = "'%s'";
-          }
-          break;
-      }
-    }
-    db_query('INSERT INTO {users} ('. implode(', ', $fields) .') VALUES ('. implode(', ', $s) .')', $values);
-    $array['uid'] = db_last_insert_id('users', 'uid');
+    drupal_write_record('users', $array);
 
     // Build the initial user object.
     $user = user_load(array('uid' => $array['uid']));
 
     user_module_invoke('insert', $array, $user, $category);
 
-    // Build and save the serialized data field now
+    // Note, we wait with saving the data column to prevent module-handled
+    // fields from being saved there.
     $data = array();
     foreach ($array as $key => $value) {
       if ((substr($key, 0, 4) !== 'auth') && ($key != 'roles') && (!in_array($key, $user_fields)) && ($value !== NULL)) {
         $data[$key] = $value;
       }
     }
-    db_query("UPDATE {users} SET data = '%s' WHERE uid = %d", serialize($data), $user->uid);
+    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($array['roles']) && is_array($array['roles'])) {
@@ -479,23 +460,6 @@ function user_is_blocked($name) {
   return $deny;
 }
 
-function user_fields() {
-  static $fields;
-
-  if (!$fields) {
-    $result = db_query('SELECT * FROM {users} WHERE uid = 1');
-    if ($field = db_fetch_array($result)) {
-      $fields = array_keys($field);
-    }
-    else {
-      // Make sure we return the default fields at least
-      $fields = array('uid', 'name', 'pass', 'mail', 'picture', 'mode', 'sort', 'threshold', 'theme', 'signature', 'created', 'access', 'login', 'status', 'timezone', 'language', 'init', 'data');
-    }
-  }
-
-  return $fields;
-}
-
 /**
  * Implementation of hook_perm().
  */
@@ -2096,7 +2060,7 @@ function user_register_submit($form, &$f
     return;
   }
   //the unset below is needed to prevent these form values from being saved as user data
-  unset($form_state['values']['form_token'], $form_state['values']['submit'], $form_state['values']['op'], $form_state['values']['notify'], $form_state['values']['form_id'], $form_state['values']['affiliates'], $form_state['values']['destination']);
+  unset($form_state['values']['form_token'], $form_state['values']['submit'], $form_state['values']['op'], $form_state['values']['notify'], $form_state['values']['form_id'], $form_state['values']['affiliates'], $form_state['values']['destination'], $form_state['values']['form_build_id']);
 
   $merge_data = array('pass' => $pass, 'init' => $mail, 'roles' => $roles);
   if (!$admin) {
Index: modules/user/user.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.pages.inc,v
retrieving revision 1.1
diff -u -F^f -r1.1 user.pages.inc
--- modules/user/user.pages.inc	10 Sep 2007 13:14:38 -0000	1.1
+++ modules/user/user.pages.inc	7 Oct 2007 13:17:11 -0000
@@ -336,7 +336,7 @@ function user_edit_validate($form, &$for
 function user_edit_submit($form, &$form_state) {
   $account = $form_state['values']['_account'];
   $category = $form_state['values']['_category'];
-  unset($form_state['values']['_account'], $form_state['values']['op'], $form_state['values']['submit'], $form_state['values']['delete'], $form_state['values']['form_token'], $form_state['values']['form_id'], $form_state['values']['_category']);
+  unset($form_state['values']['_account'], $form_state['values']['op'], $form_state['values']['submit'], $form_state['values']['delete'], $form_state['values']['form_token'], $form_state['values']['form_id'], $form_state['values']['_category'], $form_state['values']['form_build_id']);
   user_module_invoke('submit', $form_state['values'], $account, $category);
   user_save($account, $form_state['values'], $category);
 
