Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.326
diff -u -p -r1.326 form.inc
--- includes/form.inc	30 Mar 2009 03:15:40 -0000	1.326
+++ includes/form.inc	3 Apr 2009 05:50:48 -0000
@@ -404,7 +404,7 @@ function drupal_execute($form_id, &$form
  *   builder functions as well.
  */
 function drupal_retrieve_form($form_id, &$form_state) {
-  static $forms;
+  $forms = &drupal_static(__FUNCTION__);
 
   // 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
@@ -490,7 +490,7 @@ function drupal_process_form($form_id, &
     // cache when a form is processed, so scenarios that result in
     // the form being built behind the scenes and again for the
     // browser don't increment all the element IDs needlessly.
-    form_clean_id(NULL, TRUE);
+    drupal_static_reset('form_clean_id');
 
     if ((!empty($form_state['submitted'])) && !form_get_errors() && empty($form_state['rebuild'])) {
       $form_state['redirect'] = NULL;
@@ -655,7 +655,7 @@ function drupal_prepare_form($form_id, &
  *   not be repeated in the submission step.
  */
 function drupal_validate_form($form_id, $form, &$form_state) {
-  static $validated_forms = array();
+  $validated_forms = &drupal_static(__FUNCTION__, array());
 
   if (isset($validated_forms[$form_id]) && empty($form_state['must_validate'])) {
     return;
@@ -757,7 +757,7 @@ function drupal_redirect_form($form, $re
  *   theming, and hook_form_alter functions.
  */
 function _form_validate($elements, &$form_state, $form_id = NULL) {
-  static $complete_form;
+  $complete_form = &drupal_static(__FUNCTION__);
 
   // Also used in the installer, pre-database setup.
   $t = get_t();
@@ -786,6 +786,7 @@ function _form_validate($elements, &$for
 
       if (isset($elements['#options']) && isset($elements['#value'])) {
         if ($elements['#type'] == 'select') {
+          drupal_static_reset('form_options_flatten');
           $options = form_options_flatten($elements['#options']);
         }
         else {
@@ -884,17 +885,12 @@ function form_execute_handlers($type, &$
  *   element where the #parents array starts with 'foo'.
  * @param $message
  *   The error message to present to the user.
- * @param $reset
- *   Reset the form errors static cache.
  * @return
  *   Never use the return value of this function, use form_get_errors and
  *   form_get_error instead.
  */
-function form_set_error($name = NULL, $message = '', $reset = FALSE) {
-  static $form = array();
-  if ($reset) {
-    $form = array();
-  }
+function form_set_error($name = NULL, $message = '') {
+  $form = &drupal_static(__FUNCTION__, array());
   if (isset($name) && !isset($form[$name])) {
     $form[$name] = $message;
     if ($message) {
@@ -953,7 +949,9 @@ function form_error(&$element, $message 
  *   $_POST data.
  */
 function form_builder($form_id, $form, &$form_state) {
-  static $complete_form, $cache, $file;
+  $complete_form = &drupal_static(__FUNCTION__);
+  $cache = &drupal_static(__FUNCTION__ . 'cache');
+  $file = &drupal_static(__FUNCTION__ . 'file');
 
   // Initialize as unprocessed.
   $form['#processed'] = FALSE;
@@ -1446,12 +1444,8 @@ function _form_set_value(&$form_values, 
   }
 }
 
-function form_options_flatten($array, $reset = TRUE) {
-  static $return;
-
-  if ($reset) {
-    $return = array();
-  }
+function form_options_flatten($array) {
+  $return = &drupal_static(__FUNCTION__);;
 
   foreach ($array as $key => $value) {
     if (is_object($value)) {
@@ -1777,7 +1771,7 @@ function date_validate($form) {
  * Helper function for usage with drupal_map_assoc to display month names.
  */
 function map_month($month) {
-  static $months = array(
+  $months =  = &drupal_static(__FUNCTION__, array(
     1 => 'Jan',
     2 => 'Feb',
     3 => 'Mar',
@@ -1790,7 +1784,7 @@ function map_month($month) {
     10 => 'Oct',
     11 => 'Nov',
     12 => 'Dec',
-  );
+  ));
   return t($months[$month]);
 }
 
@@ -1981,7 +1975,7 @@ function theme_text_format_wrapper($elem
  *   drupal_add_js.
  */
 function form_process_ahah($element) {
-  static $js_added = array();
+  $js_added =  = &drupal_static(__FUNCTION__, array());
   // Add a reasonable default event handler if none specified.
   if (isset($element['#ahah']) && !isset($element['#ahah']['event'])) {
     switch ($element['#type']) {
@@ -2546,22 +2540,11 @@ function _form_set_class(&$element, $cla
  *
  * @param $id
  *   The ID to clean.
- * @param $flush
- *   If set to TRUE, the function will flush and reset the static array
- *   which is built to test the uniqueness of element IDs. This is only
- *   used if a form has completed the validation process. This parameter
- *   should never be set to TRUE if this function is being called to
- *   assign an ID to the #ID element.
  * @return
  *   The cleaned ID.
  */
-function form_clean_id($id = NULL, $flush = FALSE) {
-  static $seen_ids = array();
-
-  if ($flush) {
-    $seen_ids = array();
-    return;
-  }
+function form_clean_id($id = NULL) {
+  $seen_ids =  = &drupal_static(__FUNCTION__, array());
   $id = str_replace(array('][', '_', ' '), '-', $id);
 
   // Ensure IDs are unique. The first occurrence is held but left alone.
@@ -2855,7 +2838,7 @@ function batch_process($redirect = NULL,
  * Retrieve the current batch.
  */
 function &batch_get() {
-  static $batch = array();
+  $batch = &drupal_static(__FUNCTION__, array());
   return $batch;
 }
 
Index: modules/field/field.form.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.form.inc,v
retrieving revision 1.6
diff -u -p -r1.6 field.form.inc
--- modules/field/field.form.inc	26 Mar 2009 13:31:24 -0000	1.6
+++ modules/field/field.form.inc	3 Apr 2009 05:50:48 -0000
@@ -393,7 +393,7 @@ function field_add_more_js($bundle_name,
   // Just grab the data we need.
   $form_state['values'] = $form_state_copy['values'];
   // Reset cached ids, so that they don't affect the actual form we output.
-  form_clean_id(NULL, TRUE);
+  drupal_static_reset('form_clean_id');
 
   // Sort the $form_state['values'] we just built *and* the incoming $_POST data
   // according to d-n-d reordering.
Index: modules/node/node.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.admin.inc,v
retrieving revision 1.43
diff -u -p -r1.43 node.admin.inc
--- modules/node/node.admin.inc	20 Mar 2009 08:14:34 -0000	1.43
+++ modules/node/node.admin.inc	3 Apr 2009 05:50:48 -0000
@@ -317,6 +317,7 @@ function node_filter_form_submit($form, 
         $filter = $form_state['values']['filter'];
 
         // Flatten the options array to accommodate hierarchical/nested options.
+        drupal_static_reset('form_options_flatten');
         $flat_options = form_options_flatten($filters[$filter]['options']);
 
         if (isset($flat_options[$form_state['values'][$filter]])) {
