Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.502
diff -u -p -r1.502 form.inc
--- includes/form.inc	7 Oct 2010 17:31:39 -0000	1.502
+++ includes/form.inc	12 Oct 2010 16:48:56 -0000
@@ -1975,6 +1975,10 @@ function _form_button_was_clicked($eleme
  *   submitted form values; altered by reference.
  */
 function form_state_values_clean(&$form_state) {
+  // Allow modules to clean up their internal values. Do this first, so they can
+  // access form_id and other Form API internals.
+  drupal_alter('form_state_values_clean', $form_state);
+
   // Remove internal Form API values.
   unset($form_state['values']['form_id'], $form_state['values']['form_token'], $form_state['values']['form_build_id'], $form_state['values']['op']);
 
Index: modules/node/content_types.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/content_types.inc,v
retrieving revision 1.118
diff -u -p -r1.118 content_types.inc
--- modules/node/content_types.inc	7 Oct 2010 00:28:20 -0000	1.118
+++ modules/node/content_types.inc	12 Oct 2010 16:47:37 -0000
@@ -329,6 +329,7 @@ function node_type_form_submit($form, &$
     return;
   }
 
+  form_state_values_clean($form_state);
   $variables = $form_state['values'];
 
   // Remove everything that's been saved already - whatever's left is assumed
@@ -339,8 +340,6 @@ function node_type_form_submit($form, &$
     }
   }
 
-  unset($variables['form_token'], $variables['op'], $variables['submit'], $variables['delete'], $variables['reset'], $variables['form_id'], $variables['form_build_id']);
-
   // Save or reset persistent variable values.
   foreach ($variables as $key => $value) {
     $variable_new = $key . '_' . $type->type;
Index: modules/system/system.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.api.php,v
retrieving revision 1.197
diff -u -p -r1.197 system.api.php
--- modules/system/system.api.php	2 Oct 2010 01:22:41 -0000	1.197
+++ modules/system/system.api.php	12 Oct 2010 17:07:18 -0000
@@ -1517,6 +1517,30 @@ function hook_forms($form_id, $args) {
 }
 
 /**
+ * Clean submitted form values before they are processed further.
+ *
+ * This hook is invoked from form_state_values_clean() before Form API removes
+ * all of its internal form values. It is typically used to clean up temporary,
+ * module-specific values from $form_state['values'] by moving them into another
+ * location in $form_state, so they do not get processed by the form's primary
+ * submit handler.
+ *
+ * @param $form_state
+ *   The current state of the form, containing all submitted form values.
+ */
+function hook_form_state_values_clean_alter(&$form_state) {
+  if ($form_state['values']['form_id'] == 'example_form') {
+    // Remove our temporary value, if it exists.
+    if (isset($form_state['values']['example'])) {
+      // Leverage Form API's special $form_state['temporary'] storage to
+      // prevent the values from being cached.
+      $form_state['temporary']['example'] = $form_state['values']['example'];
+      unset($form_state['values']['example']);
+    }
+  }
+}
+
+/**
  * Perform setup tasks. See also, hook_init.
  *
  * This hook is run at the beginning of the page request. It is typically
