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 06:15:06 -0000
@@ -4669,7 +4669,6 @@ function drupal_render_page($page) {
  *   The rendered HTML.
  */
 function drupal_render(&$elements) {
-  static $defaults;
   // Early-return nothing if user does not have access.
   if (!isset($elements) || (isset($elements['#access']) && !$elements['#access'])) {
     return;
@@ -4687,14 +4686,8 @@ function drupal_render(&$elements) {
 
   // If the default values for this element have not been loaded yet, populate
   // them.
-  if (isset($elements['#type']) && empty($elements['#defaults_loaded'])) {
-    $elements += element_info($elements['#type']);
-  }
-  else {
-    if (!isset($defaults)) {
-      $defaults = element_basic_defaults();
-    }
-    $elements += $defaults;
+  if (empty($elements['#defaults_loaded'])) {
+    $elements += element_info(isset($elements['#type']) ? $elements['#type'] : 'defaults');
   }
 
   // If #markup is not empty and no theme function is set, use theme_markup.
@@ -4981,30 +4974,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'];
 }
 
 /**
