Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.316
diff -u -p -r1.316 bootstrap.inc
--- includes/bootstrap.inc	30 Oct 2009 22:33:35 -0000	1.316
+++ includes/bootstrap.inc	31 Oct 2009 07:40:38 -0000
@@ -2015,27 +2015,28 @@ function registry_rebuild() {
  * @return
  *   Returns a variable by reference if $reset is FALSE.
  */
+$GLOBALS['drupal_static'] = array();
 function &drupal_static($name, $default_value = NULL, $reset = FALSE) {
-  static $data = array();
+  global $drupal_static;
 
   // Reset a single value, or all values.
   if ($reset) {
     if (isset($name)) {
-      unset($data[$name]);
+      unset($drupal_static[$name]);
     }
     else {
-      $data = array();
+      $drupal_static = array();
     }
     // We must return a reference to a variable.
     $dummy = NULL;
     return $dummy;
   }
 
-  if (!isset($data[$name])) {
-    $data[$name] = $default_value;
+  if (!isset($drupal_static[$name])) {
+    $drupal_static[$name] = $default_value;
   }
 
-  return $data[$name];
+  return $drupal_static[$name];
 }
 
 /**
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1031
diff -u -p -r1.1031 common.inc
--- includes/common.inc	27 Oct 2009 19:29:12 -0000	1.1031
+++ includes/common.inc	31 Oct 2009 07:40:39 -0000
@@ -4669,7 +4669,8 @@ function drupal_render_page($page) {
  *   The rendered HTML.
  */
 function drupal_render(&$elements) {
-  static $defaults;
+  global $drupal_static;
+
   // Early-return nothing if user does not have access.
   if (!isset($elements) || (isset($elements['#access']) && !$elements['#access'])) {
     return;
@@ -4691,8 +4692,12 @@ function drupal_render(&$elements) {
     $elements += element_info($elements['#type']);
   }
   else {
-    if (!isset($defaults)) {
-      $defaults = element_basic_defaults();
+    if (isset($drupal_static[__FUNCTION__])) {
+      $defaults = &$drupal_static[__FUNCTION__];
+    }
+    else {
+      $defaults = &drupal_static(__FUNCTION__);
+      $defaults = element_info('defaults');
     }
     $elements += $defaults;
   }
@@ -4981,30 +4986,30 @@ function element_info($type) {
   $cache = &drupal_static(__FUNCTION__);
 
   if (!isset($cache)) {
-    $basic_defaults = element_basic_defaults();
+    $basic_defaults = array(
+      '#description' => '',
+      '#title' => '',
+      '#attributes' => array(),
+      '#required' => FALSE,
+      '#attached' => array(),
+    );
+
+    // Load all the elements, keyed by their #type.
     $cache = module_invoke_all('element_info');
+
     foreach ($cache as $element_type => $info) {
       $cache[$element_type] = array_merge_recursive($basic_defaults, $info);
       $cache[$element_type]['#type'] = $element_type;
     }
+
+    // Add default properties.
+    $cache['defaults'] = $basic_defaults;
+
     // Allow modules to alter the element type defaults.
     drupal_alter('element_info', $cache);
   }
 
-  return isset($cache[$type]) ? $cache[$type] : array();
-}
-
-/**
- * Retrieve the basic default properties that are common to all elements.
- */
-function element_basic_defaults() {
-  return array(
-    '#description' => '',
-    '#title' => '',
-    '#attributes' => array(),
-    '#required' => FALSE,
-    '#attached' => array(),
-  );
+  return isset($cache[$type]) ? $cache[$type] : $cache['defaults'];
 }
 
 /**
