diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-12-01 16:28:57 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-12-01 16:28:57 +0000 |
commit | 65f1c9fa248c47b472698aedf9b34f52aac54865 (patch) | |
tree | f7152c26c60172e0ead80fbe04da5dc02a5fe7c5 /includes/form.inc | |
parent | 6083731ce4b20e1752bdfb636db4e33196003193 (diff) | |
download | brdo-65f1c9fa248c47b472698aedf9b34f52aac54865.tar.gz brdo-65f1c9fa248c47b472698aedf9b34f52aac54865.tar.bz2 |
- Patch #647130 by fago, sun: cache only once when rebuilding a form.
Diffstat (limited to 'includes/form.inc')
-rw-r--r-- | includes/form.inc | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/includes/form.inc b/includes/form.inc index ff918dc43..39090a349 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -220,21 +220,6 @@ function drupal_build_form($form_id, &$form_state) { // altering the $form_state variable, which is passed into them by // reference. drupal_process_form($form_id, $form, $form_state); - - // After processing the form, the form builder or a #process callback may - // have set $form_state['cache'] to indicate that the original form and the - // $form_state shall be cached. But the form may only be cached if the - // special 'no_cache' property is not set to TRUE. - if (!empty($form_state['cache']) && empty($form_state['no_cache'])) { - // Cache the original, unprocessed form upon initial build of the form. - if (isset($original_form)) { - form_set_cache($form_build_id, $original_form, $form_state); - } - // After processing a cached form, only update the cached form state. - else { - form_set_cache($form_build_id, NULL, $form_state); - } - } } // Most simple, single-step forms will be finished by this point -- @@ -252,6 +237,20 @@ function drupal_build_form($form_id, &$form_state) { if ($form_state['rebuild'] && $form_state['submitted'] && !form_get_errors()) { $form = drupal_rebuild_form($form_id, $form_state); } + // After processing the form, the form builder or a #process callback may + // have set $form_state['cache'] to indicate that the original form and the + // $form_state shall be cached. But the form may only be cached if the + // special 'no_cache' property is not set to TRUE and we are not rebuilding. + elseif (isset($form_build_id) && $form_state['cache'] && empty($form_state['no_cache'])) { + // Cache the original, unprocessed form upon initial build of the form. + if (isset($original_form)) { + form_set_cache($form_build_id, $original_form, $form_state); + } + // After processing a cached form, only update the cached form state. + else { + form_set_cache($form_build_id, NULL, $form_state); + } + } // Don't override #theme if someone already set it. if (!isset($form['#theme'])) { |