? modules/node/node.content_forms.inc
Index: modules/book/book.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.module,v
retrieving revision 1.429
diff -u -p -r1.429 book.module
--- modules/book/book.module	30 Jul 2007 18:20:21 -0000	1.429
+++ modules/book/book.module	4 Aug 2007 18:00:14 -0000
@@ -329,7 +329,12 @@ function book_form_alter(&$form, $form_s
       $form['book']['pick-book'] = array(
         '#type' => 'submit',
         '#value' => t('Change book (update list of parents)'),
-        '#submit' => array('book_pick_book_submit'),
+         // Submit the node form so the parent select options get updated.
+         // This is typically only used when JS is disabled.  Since the parent options
+         // won't be changed via AJAX, a button is provided in the node form to submit
+         // the form and generate options in the parent select corresponding to the
+         // selected book.  This is similar to what happens during a node preview.
+        '#submit' => array('node_form_submit_build_node'),
         '#weight' => 20,
       );
     }
@@ -337,23 +342,6 @@ function book_form_alter(&$form, $form_s
 }
 
 /**
- * Submit the node form so the parent select options get updated.
- *
- * This is typically only used when JS is disabled.  Since the parent options
- * won't be changed via AJAX, a button is provided in the node form to submit
- * the form and generate options in the parent select corresponding to the
- * selected book.  This is similar to what happens during a node preview.
- */
-function book_pick_book_submit($form, &$form_state) {
-  // Unset any button-level handlers, execute all the form-level submit functions
-  // to process the form values into an updated node, and rebuild the form.
-  unset($form_state['submit_handlers']);
-  form_execute_handlers('submit', $form, $form_state);
-  $form_state['rebuild'] = TRUE;
-  $form_state['node'] = $form_state['values'];
-}
-
-/**
  * Build the parent selection form element for the node form or outline tab
  *
  * This function is also called when generating a new set of options during the
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.865
diff -u -p -r1.865 node.module
--- modules/node/node.module	2 Aug 2007 20:08:52 -0000	1.865
+++ modules/node/node.module	4 Aug 2007 18:00:14 -0000
@@ -2231,15 +2231,23 @@ function node_form(&$form_state, $node) 
   return $form;
 }
 
-function node_form_build_preview($form, &$form_state) {
-  // Unset any button-level handlers, execute all the form-level submit functions
-  // to process the form values into an updated node, and rebuild the form.
+/**
+ * Build a node by processing submitted form values and prepare for a form rebuild.
+ */
+function node_form_submit_build_node($form, &$form_state) {
+  // Unset any button-level handlers, execute all the form-level submit
+  // functions to process the form values into an updated node.
   unset($form_state['submit_handlers']);
   form_execute_handlers('submit', $form, $form_state);
-
-  $form_state['node_preview'] = node_preview((object)$form_state['values']);
+  $node = node_submit($form_state['values']);
+  $form_state['node'] = (array)$node;
   $form_state['rebuild'] = TRUE;
-  $form_state['node'] = $form_state['values'];
+  return $node;
+}
+
+function node_form_build_preview($form, &$form_state) {
+  $node = node_form_submit_build_node($form, $form_state);
+  $form_state['node_preview'] = node_preview($node);
 }
 
 function theme_node_form($form) {
@@ -2391,32 +2399,28 @@ function theme_node_log_message($log) {
 function node_form_submit($form, &$form_state) {
   global $user;
 
-  // Unset any button-level handlers, and execute all the form-level submit
-  // functions to process the form values into an updated node.
-  unset($form_state['submit_handlers']);
-  form_execute_handlers('submit', $form, $form_state);
-
-  // Fix up the node when required:
-  $node = node_submit($form_state['values']);
-
-  // Prepare the node's body:
-  if ($node->nid) {
-    node_save($node);
-    watchdog('content', '@type: updated %title.', array('@type' => $node->type, '%title' => $node->title), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid));
-    drupal_set_message(t('The %post has been updated.', array('%post' => node_get_types('name', $node))));
+  $node = node_form_submit_build_node($form, $form_state);
+  $insert = empty($node->nid);
+  node_save($node);
+  $node_link = l(t('view'), 'node/'. $node->nid);
+  $watchdog_args = array('@type' => $node->type, '%title' => $node->title);
+  $t_args = array('%post' => node_get_types('name', $node));
+
+  if ($insert) {
+    watchdog('content', '@type: added %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
+    drupal_set_message(t('Your %post has been created.', $t_args));
   }
   else {
-    node_save($node);
-    watchdog('content', '@type: added %title.', array('@type' => $node->type, '%title' => $node->title), WATCHDOG_NOTICE, l(t('view'), "node/$node->nid"));
-    drupal_set_message(t('Your %post has been created.', array('%post' => node_get_types('name', $node))));
-  }
-  if ($node->nid) {
-    if (node_access('view', $node)) {
-      $form_state['redirect'] = 'node/'. $node->nid;
-    }
+    watchdog('content', '@type: updated %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
+    drupal_set_message(t('The %post has been updated.', $t_args));
   }
-  // it is very unlikely we get here
-  return FALSE;
+  if ($node->nid && node_access('view', $node)) {
+    unset($form_state['rebuild']);
+    $form_state['redirect'] = 'node/'. $node->nid;
+  }
+  // In the unlikely case something went wrong on save, the node will be
+  // rebuilt and node form redisplayed the same way as in preview.
+  drupal_set_message(t('The node could not be saved.'), 'error');
 }
 
 /**
Index: modules/upload/upload.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/upload/upload.module,v
retrieving revision 1.174
diff -u -p -r1.174 upload.module
--- modules/upload/upload.module	30 Jul 2007 22:53:10 -0000	1.174
+++ modules/upload/upload.module	4 Aug 2007 18:00:15 -0000
@@ -493,7 +493,7 @@ function _upload_form($node) {
       '#name' => 'attach',
       '#ahah_path' => 'upload/js',
       '#ahah_wrapper' => 'attach-wrapper',
-      '#submit' => array(),
+      '#submit' => array('node_form_submit_build_node'),
     );
   }
 
