? sites/all/modules/views
? sites/default/files
? sites/default/private
? sites/default/settings.php
Index: includes/ajax.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/ajax.inc,v
retrieving revision 1.25
diff -u -p -r1.25 ajax.inc
--- includes/ajax.inc	27 Jan 2010 11:19:11 -0000	1.25
+++ includes/ajax.inc	6 Mar 2010 02:39:42 -0000
@@ -322,7 +322,7 @@ function ajax_form_callback() {
 
   // This call recreates the form relying solely on the $form_state that
   // drupal_process_form() set up.
-  $form = drupal_rebuild_form($form_id, $form_state, $form_build_id);
+  $form = ajax_rebuild_form($form_id, $form_state, $form['#action'], $form_build_id);
 
   // $triggering_element_path in a simple form might just be 'myselect', which
   // would mean we should use the element $form['myselect']. For nested form
@@ -517,6 +517,65 @@ function ajax_process_form($element, &$f
 }
 
 /**
+ * Retrieves a form, caches it and processes it again setting the action of the
+ * old form.
+ *
+ * If your AHAH callback simulates the pressing of a button, then your AHAH
+ * callback will need to do the same as what drupal_get_form would do when the
+ * button is pressed: get the form from the cache, run drupal_process_form over
+ * it and then if it needs rebuild, run ajax_rebuild_form over it. Then send
+ * back a part of the returned form.
+ * $form_state['clicked_button']['#array_parents'] will help you to find which
+ * part.
+ *
+ * @param $form_id
+ *   The unique string identifying the desired form. If a function
+ *   with that name exists, it is called to build the form array.
+ *   Modules that need to generate the same form (or very similar forms)
+ *   using different $form_ids can implement hook_forms(), which maps
+ *   different $form_id values to the proper form constructor function. Examples
+ *   may be found in node_forms(), search_forms(), and user_forms().
+ * @param $form_state
+ *   A keyed array containing the current state of the form.
+ * @param $form_action
+ *   The action property of the form.
+ * @param $form_build_id
+ *   Form cache id used to re-cache the form with the same csid.
+ * @return
+ *   The newly built form.
+ */
+ function ajax_rebuild_form($form_id, &$form_state, $form_action, $form_build_id) {
+  // AJAX forms call ajax_rebuild_form() even when $form_state['rebuild'] 
+  // isn't set, but _form_builder_handle_input_element() needs to distinguish a
+  // rebuild from an initial build in order to process user input correctly.
+  // Form constructors and form processing functions may also need to handle a
+  // rebuild differently than an initial build.
+  $form_state['rebuild'] = TRUE;
+
+  $form = drupal_retrieve_form($form_id, $form_state);
+
+  $form['#build_id'] = $form_build_id;
+  drupal_prepare_form($form_id, $form, $form_state);
+
+  $form['#action'] = $form_action;
+
+  if (empty($form_state['no_cache'])) {
+    // We cache the form structure and the form state so it can be retrieved
+    // later for validation.
+    form_set_cache($form_build_id, $form, $form_state);
+  }
+
+  // Clear out all group associations as these might be different when
+  // re-rendering the form.
+  $form_state['groups'] = array();
+
+  // Do not call drupal_process_form(), since it would prevent the rebuilt form
+  // to submit.
+  $form = form_builder($form_id, $form, $form_state);
+  return $form;
+}
+
+/**
  * @} End of "defgroup ajax".
  */
 
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.435
diff -u -p -r1.435 form.inc
--- includes/form.inc	4 Mar 2010 09:07:27 -0000	1.435
+++ includes/form.inc	6 Mar 2010 02:39:43 -0000
@@ -286,14 +286,6 @@ function form_state_defaults() {
 /**
  * Retrieves a form, caches it and processes it again.
  *
- * If your AHAH callback simulates the pressing of a button, then your AHAH
- * callback will need to do the same as what drupal_get_form would do when the
- * button is pressed: get the form from the cache, run drupal_process_form over
- * it and then if it needs rebuild, run drupal_rebuild_form over it. Then send
- * back a part of the returned form.
- * $form_state['clicked_button']['#array_parents'] will help you to find which
- * part.
- *
  * @param $form_id
  *   The unique string identifying the desired form. If a function
  *   with that name exists, it is called to build the form array.
@@ -303,34 +295,26 @@ function form_state_defaults() {
  *   may be found in node_forms(), search_forms(), and user_forms().
  * @param $form_state
  *   A keyed array containing the current state of the form.
- * @param $form_build_id
- *   If the AHAH callback calling this function only alters part of the form,
- *   then pass in the existing form_build_id so we can re-cache with the same
- *   csid.
  * @return
  *   The newly built form.
  */
-function drupal_rebuild_form($form_id, &$form_state, $form_build_id = NULL) {
-  // AJAX and other contexts may call drupal_rebuild_form() even when
-  // $form_state['rebuild'] isn't set, but _form_builder_handle_input_element()
-  // needs to distinguish a rebuild from an initial build in order to process
-  // user input correctly. Form constructors and form processing functions may
-  // also need to handle a rebuild differently than an initial build.
+function drupal_rebuild_form($form_id, &$form_state) {
+  // Contexts may call drupal_rebuild_form() even when $form_state['rebuild']
+  // isn't set, but _form_builder_handle_input_element() needs to distinguish a 
+  // rebuild from an initial build in order to process user input correctly.
+  // Form constructors and form processing functions may also need to handle a
+  // rebuild differently than an initial build.
   $form_state['rebuild'] = TRUE;
 
   $form = drupal_retrieve_form($form_id, $form_state);
 
-  if (!isset($form_build_id)) {
-    // We need a new build_id for the new version of the form.
-    $form_build_id = 'form-' . md5(mt_rand());
-  }
-  $form['#build_id'] = $form_build_id;
+  $form['#build_id'] = 'form-' . md5(mt_rand());
   drupal_prepare_form($form_id, $form, $form_state);
 
   if (empty($form_state['no_cache'])) {
     // We cache the form structure and the form state so it can be retrieved
     // later for validation.
-    form_set_cache($form_build_id, $form, $form_state);
+    form_set_cache($form['#build_id'], $form, $form_state);
   }
 
   // Clear out all group associations as these might be different when
Index: modules/file/file.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/file/file.module,v
retrieving revision 1.19
diff -u -p -r1.19 file.module
--- modules/file/file.module	11 Feb 2010 17:44:47 -0000	1.19
+++ modules/file/file.module	6 Mar 2010 02:39:44 -0000
@@ -239,7 +239,7 @@ function file_ajax_upload() {
 
   // This call recreates the form relying solely on the form_state that the
   // drupal_process_form() set up.
-  $form = drupal_rebuild_form($form_id, $form_state, $form_build_id);
+  $form = ajax_rebuild_form($form_id, $form_state, $form['#action'], $form_build_id);
 
   // Retrieve the element to be rendered.
   foreach ($form_parents as $parent) {
