Index: includes/ajax.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/ajax.inc,v retrieving revision 1.7 diff -u -p -r1.7 ajax.inc --- includes/ajax.inc 27 Aug 2009 04:40:12 -0000 1.7 +++ includes/ajax.inc 27 Aug 2009 06:41:02 -0000 @@ -189,7 +189,6 @@ function ajax_get_form() { // The form needs to be processed; prepare for that by setting a few internal // variables. $form_state['input'] = $_POST; - $form_state['args'] = $form['#args']; $form_id = $form['#form_id']; return array($form, $form_state, $form_id, $form_build_id); Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.367 diff -u -p -r1.367 form.inc --- includes/form.inc 27 Aug 2009 04:40:12 -0000 1.367 +++ includes/form.inc 27 Aug 2009 06:42:46 -0000 @@ -72,7 +72,7 @@ function drupal_get_form($form_id) { $args = func_get_args(); // Remove $form_id from the arguments. array_shift($args); - $form_state['args'] = $args; + $form_state['build_info']['args'] = $args; return drupal_build_form($form_id, $form_state); } @@ -151,23 +151,22 @@ function drupal_build_form($form_id, &$f // object, we're hitting the form for the first time and we need // to build it from scratch. if (!isset($form)) { - $form = drupal_retrieve_form($form_id, $form_state); - $form_build_id = 'form-' . md5(uniqid(mt_rand(), TRUE)); - $form['#build_id'] = $form_build_id; - // Record the filepath of the include file containing the original form, // so the form builder callbacks can be loaded when the form is being // rebuilt on a different path (such as 'system/ajax'). // @see form_get_cache() - // @see drupal_retrieve_form() // menu_get_item() is not available at installation time. if (!defined('MAINTENANCE_MODE')) { $item = menu_get_item(); if (!empty($item['file'])) { - $form['#include_file'] = $item['file']; + $form_state['build_info']['file'] = $item['file']; } } + $form = drupal_retrieve_form($form_id, $form_state); + $form_build_id = 'form-' . md5(uniqid(mt_rand(), TRUE)); + $form['#build_id'] = $form_build_id; + // Fix the form method, if it is 'get' in $form_state, but not in $form. if ($form_state['method'] == 'get' && !isset($form['#method'])) { $form['#method'] = 'get'; @@ -207,7 +206,6 @@ 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()) { $form = drupal_rebuild_form($form_id, $form_state); } @@ -231,6 +229,7 @@ function form_state_defaults() { return array( 'rebuild' => FALSE, 'redirect' => NULL, + 'build_info' => array(), 'storage' => NULL, 'submitted' => FALSE, 'programmed' => FALSE, @@ -254,9 +253,6 @@ function form_state_defaults() { * $form_state['clicked_button']['#array_parents'] will help you to find which * part. * - * When getting a form from the cache, the $form_id must be shifted off from - * $form['#args'], so the resulting array can be given to $form_state['args']. - * * @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. @@ -312,19 +308,19 @@ function drupal_rebuild_form($form_id, & function form_get_cache($form_build_id, &$form_state) { if ($cached = cache_get('form_' . $form_build_id, 'cache_form')) { $form = $cached->data; - // If the original form is contained in an optional include file, load the - // file and re-populate $form_state for subsequent rebuilds. - // @see drupal_build_form() - // @see drupal_retrieve_form() - if (!empty($form['#include_file']) && file_exists($form['#include_file'])) { - require_once DRUPAL_ROOT . '/' . $form['#include_file']; - $form_state['include_file'] = $form['#include_file']; - } global $user; if ((isset($form['#cache_token']) && drupal_valid_token($form['#cache_token'])) || (!isset($form['#cache_token']) && !$user->uid)) { if ($cached = cache_get('storage_' . $form_build_id, 'cache_form')) { - $form_state['storage'] = $cached->data; + // Re-populate $form_state for subsequent rebuilds. + $form_state['build_info'] = $cached->data['build_info']; + $form_state['storage'] = $cached->data['storage']; + + // If the original form is contained in an include file, load the file. + // @see drupal_build_form() + if (!empty($form_state['build_info']['file']) && file_exists($form_state['build_info']['file'])) { + require_once DRUPAL_ROOT . '/' . $form_state['build_info']['file']; + } } return $form; } @@ -342,8 +338,11 @@ function form_set_cache($form_build_id, $form['#cache_token'] = drupal_get_token(); } cache_set('form_' . $form_build_id, $form, 'cache_form', REQUEST_TIME + $expire); - if (!empty($form_state['storage'])) { - cache_set('storage_' . $form_build_id, $form_state['storage'], 'cache_form', REQUEST_TIME + $expire); + if (!empty($form_state['build_info']) || !empty($form_state['storage'])) { + cache_set('storage_' . $form_build_id, array( + 'build_info' => $form_state['build_info'], + 'storage' => $form_state['storage'], + ), 'cache_form', REQUEST_TIME + $expire); } } @@ -392,11 +391,11 @@ function form_set_cache($form_build_id, * @endcode */ function drupal_form_submit($form_id, &$form_state) { - if (!isset($form_state['args'])) { + if (!isset($form_state['build_info']['args'])) { $args = func_get_args(); array_shift($args); array_shift($args); - $form_state['args'] = $args; + $form_state['build_info']['args'] = $args; } $form = drupal_retrieve_form($form_id, $form_state); @@ -436,7 +435,7 @@ function drupal_retrieve_form($form_id, // We save two copies of the incoming arguments: one for modules to use // when mapping form ids to constructor functions, and another to pass to // the constructor function itself. - $args = $form_state['args']; + $args = $form_state['build_info']['args']; // We first check to see if there's a function named after the $form_id. // If there is, we simply pass the arguments on to it to get the form. @@ -473,15 +472,6 @@ function drupal_retrieve_form($form_id, // Otherwise, call the function named after the form id. $form = call_user_func_array(isset($callback) ? $callback : $form_id, $args); $form['#form_id'] = $form_id; - $form['#args'] = $form_state['args']; - - // Whenever this form is (re)built, restore the include file property from - // $form_state, if existent. - // @see drupal_build_form() - // @see form_get_cache() - if (!empty($form_state['include_file'])) { - $form['#include_file'] = $form_state['include_file']; - } return $form; } Index: misc/ajax.js =================================================================== RCS file: /cvs/drupal/drupal/misc/ajax.js,v retrieving revision 1.1 diff -u -p -r1.1 ajax.js --- misc/ajax.js 17 Aug 2009 07:12:15 -0000 1.1 +++ misc/ajax.js 27 Aug 2009 06:25:51 -0000 @@ -96,7 +96,7 @@ Drupal.ajax = function (base, element, e type: 'bar', message: 'Please wait...' }, - button: {}, + button: {} }; $.extend(this, defaults, element_settings); Index: modules/openid/openid.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/openid/openid.pages.inc,v retrieving revision 1.19 diff -u -p -r1.19 openid.pages.inc --- modules/openid/openid.pages.inc 29 Jul 2009 06:39:34 -0000 1.19 +++ modules/openid/openid.pages.inc 27 Aug 2009 06:56:29 -0000 @@ -103,12 +103,12 @@ function openid_user_delete_form($form_s function openid_user_delete_form_submit(&$form_state, $form_values) { $query = db_delete('authmap') - ->condition('uid', $form_state['#args'][0]->uid) - ->condition('aid', $form_state['#args'][1]) + ->condition('uid', $form_state['build_info']['args'][0]->uid) + ->condition('aid', $form_state['build_info']['args'][1]) ->condition('module', 'openid') ->execute(); if ($query) { drupal_set_message(t('OpenID deleted.')); } - $form_state['#redirect'] = 'user/' . $form_state['#args'][0]->uid . '/openid'; + $form_state['#redirect'] = 'user/' . $form_state['build_info']['args'][0]->uid . '/openid'; }