Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1174
diff -u -p -r1.1174 node.module
--- modules/node/node.module	2 Dec 2009 19:52:23 -0000	1.1174
+++ modules/node/node.module	3 Dec 2009 21:36:45 -0000
@@ -95,7 +95,7 @@ function node_help($path, $arg) {
       $output .= '<dd>' . t('The Node module also enables you to create multiple versions of any content, and revert to older versions using the <em>Revision information</em> settings.') . '</dd>';
       $output .= '<dt>' . t('User permissions') . '</dt>';
       $output .= '<dd>' . t('The Node module makes a number of permissions available for each content type, which can be set by role on the <a href="@permissions">permissions page</a>.', array('@permissions' => url('admin/settings/permissions'))) . '</dd>';
-      $output .= '</dl>'; 
+      $output .= '</dl>';
       return $output;
 
     case 'admin/content':
@@ -997,9 +997,8 @@ function node_save($node) {
     }
     // The changed timestamp is always updated for bookkeeping purposes (revisions, searching, ...)
     $node->changed = REQUEST_TIME;
-  
+
     $node->timestamp = REQUEST_TIME;
-    $update_node = TRUE;
 
     // When converting the title property to fields we preserved the {node}.title
     // db column for performance, setting the default language value into this
@@ -1011,51 +1010,52 @@ function node_save($node) {
 
     // Generate the node table query and the node_revisions table query.
     if ($node->is_new) {
-      drupal_write_record('node', $node);
       _node_save_revision($node, $user->uid);
+      drupal_write_record('node', $node);
+      db_update('node_revisions')
+        ->fields(array('nid' => $node->nid))
+        ->condition('vid', $node->vid)
+        ->execute();
       $op = 'insert';
     }
     else {
       drupal_write_record('node', $node, 'nid');
       if (!empty($node->revision)) {
         _node_save_revision($node, $user->uid);
+        db_update('node')
+        ->fields(array('vid' => $node->vid))
+        ->condition('nid', $node->nid)
+        ->execute();
       }
       else {
         _node_save_revision($node, $user->uid, 'vid');
-        $update_node = FALSE;
       }
       $op = 'update';
     }
-    if ($update_node) {
-      db_update('node')
-        ->fields(array('vid' => $node->vid))
-        ->condition('nid', $node->nid)
-        ->execute();
-    }
-  
+
     // Restore the title field data structure after db storage.
     $node->title = $title_field;
-  
+
     // Call the node specific callback (if any). This can be
     // node_invoke($node, 'insert') or
     // node_invoke($node, 'update').
     node_invoke($node, $op);
-  
+
     // Save fields.
     $function = "field_attach_$op";
     $function('node', $node);
-  
+
     module_invoke_all('node_' . $op, $node);
-  
+
     // Update the node access table for this node.
     node_access_acquire_grants($node);
-  
+
     // Clear internal properties.
     unset($node->is_new);
-  
+
     // Clear the page and block caches.
     cache_clear_all();
-  
+
     // Ignore slave server temporarily to give time for the
     // saved node to be propagated to the slave.
     db_ignore_slave();
