Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.375
diff -u -p -r1.375 form.inc
--- includes/form.inc	21 Sep 2009 06:44:13 -0000	1.375
+++ includes/form.inc	22 Sep 2009 23:55:38 -0000
@@ -217,8 +217,7 @@ function drupal_build_form($form_id, &$f
   // complete. We need to construct a fresh copy of the form, passing
   // in the latest $form_state in addition to any other variables passed
   // into drupal_get_form().
-
-  if ((!empty($form_state['storage']) || $form_state['rebuild']) && $form_state['submitted'] && !form_get_errors()) {
+  if ((!empty($form_state['storage']) || $form_state['rebuild']) && !form_get_errors()) {
     $form = drupal_rebuild_form($form_id, $form_state);
   }
 
Index: modules/simpletest/tests/form.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/form.test,v
retrieving revision 1.15
diff -u -p -r1.15 form.test
--- modules/simpletest/tests/form.test	18 Sep 2009 00:12:48 -0000	1.15
+++ modules/simpletest/tests/form.test	23 Sep 2009 00:05:19 -0000
@@ -394,11 +394,10 @@ class FormAPITestCase extends DrupalWebT
  * values aren't lost due to a wrong form rebuild.
  */
 class FormsFormStorageTestCase extends DrupalWebTestCase {
-
   public static function getInfo() {
     return array(
-      'name'  => 'Multistep form using form storage',
-      'description'  => 'Tests a multistep form using form storage and makes sure validation and caching works right.',
+      'name' => 'Multistep form using form storage',
+      'description' => 'Tests a multistep form using form storage and makes sure validation and caching works right.',
       'group' => 'Form API',
     );
   }
@@ -411,7 +410,6 @@ class FormsFormStorageTestCase extends D
    * Tests using the form in a usual way.
    */
   function testForm() {
-
     $user = $this->drupalCreateUser(array('access content'));
     $this->drupalLogin($user);
 
Index: modules/simpletest/tests/form_test.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/form_test.module,v
retrieving revision 1.9
diff -u -p -r1.9 form_test.module
--- modules/simpletest/tests/form_test.module	18 Sep 2009 00:12:48 -0000	1.9
+++ modules/simpletest/tests/form_test.module	23 Sep 2009 00:03:55 -0000
@@ -296,12 +296,12 @@ function form_test_mock_form_submit($for
  * @see form_storage_test_form_submit().
  */
 function form_storage_test_form($form, &$form_state) {
-  // Initialize
+  // Initialize.
   if (!isset($form_state['storage'])) {
     if (empty($form_state['input'])) {
       $_SESSION['constructions'] = 0;
     }
-    // Put the initial thing into the storage
+    // Put the initial thing into the storage.
     $form_state['storage'] = array(
       'thing' => array(
         'title' => 'none',
@@ -311,7 +311,7 @@ function form_storage_test_form($form, &
     $form_state['storage'] += array('step' => 1);
   }
 
-  // Count how often the form is constructed
+  // Count how often the form is constructed.
   $_SESSION['constructions']++;
 
   if ($form_state['storage']['step'] == 1) {
@@ -329,6 +329,7 @@ function form_storage_test_form($form, &
     $form['submit'] = array(
       '#type' => 'submit',
       '#value' => 'Continue',
+      '#submit' => array('form_storage_test_form_continue_submit'),
     );
   }
   else {
@@ -349,18 +350,24 @@ function form_storage_test_form($form, &
 }
 
 /**
+ * Multistep form first submit callback.
+ */
+function form_storage_test_form_continue_submit($form, &$form_state) {
+  $form_state['storage']['thing']['title'] = $form_state['values']['title'];
+  $form_state['storage']['thing']['value'] = $form_state['values']['value'];
+
+  $form_state['storage']['step']++;
+  drupal_set_message('Form constructions: ' . $_SESSION['constructions']);
+}
+
+/**
  * Multistep form submit callback.
  */
 function form_storage_test_form_submit($form, &$form_state) {
-  if ($form_state['storage']['step'] == 1) {
-    $form_state['storage']['thing']['title'] = $form_state['values']['title'];
-    $form_state['storage']['thing']['value'] = $form_state['values']['value'];
-  }
-  else {
-    drupal_set_message("Title: ". check_plain($form_state['storage']['thing']['title']));
-  }
+  drupal_set_message('Title: ' . check_plain($form_state['storage']['thing']['title']));
+
   $form_state['storage']['step']++;
-  drupal_set_message("Form constructions: ". $_SESSION['constructions']);
+  drupal_set_message('Form constructions: ' . $_SESSION['constructions']);
 }
 
 /**
