diff options
Diffstat (limited to 'includes/common.inc')
-rw-r--r-- | includes/common.inc | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/includes/common.inc b/includes/common.inc index 729e67652..7adc5bc47 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -4939,9 +4939,8 @@ 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'])) { + if (empty($elements) || (isset($elements['#access']) && !$elements['#access'])) { return; } @@ -4954,7 +4953,7 @@ function drupal_render(&$elements) { if (isset($elements['#cache']) && $cached_output = drupal_render_cache_get($elements)) { return $cached_output; } - + // If #markup is not empty, set #type. This allows to specify just #markup on // an element without setting #type. if (!empty($elements['#markup']) && !isset($elements['#type'])) { @@ -4966,12 +4965,6 @@ function drupal_render(&$elements) { if (isset($elements['#type']) && empty($elements['#defaults_loaded'])) { $elements += element_info($elements['#type']); } - else { - if (!isset($defaults)) { - $defaults = element_basic_defaults(); - } - $elements += $defaults; - } // Make any final changes to the element before it is rendered. This means // that the $element or the children can be altered or corrected before the @@ -5062,7 +5055,9 @@ function drupal_render_children(&$element, $children_keys = NULL) { } $output = ''; foreach ($children_keys as $key) { - $output .= drupal_render($element[$key]); + if (!empty($element[$key])) { + $output .= drupal_render($element[$key]); + } } return $output; } @@ -5166,7 +5161,9 @@ function drupal_render_cache_set($markup, $elements) { $data['#markup'] = $markup; // Persist attached data associated with this element. - $data['#attached'] = $elements['#attached']; + if (isset($elements['#attached'])) { + $data['#attached'] = $elements['#attached']; + } $bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'cache'; $expire = isset($elements['#cache']['expire']) ? $elements['#cache']['expire'] : CACHE_PERMANENT; cache_set($cid, $data, $bin, $expire); @@ -5258,10 +5255,8 @@ function element_info($type) { $cache = &drupal_static(__FUNCTION__); if (!isset($cache)) { - $basic_defaults = element_basic_defaults(); $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; } // Allow modules to alter the element type defaults. @@ -5272,19 +5267,6 @@ function element_info($type) { } /** - * 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(), - ); -} - -/** * Function used by uasort to sort structured arrays by weight, without the property weight prefix. */ function drupal_sort_weight($a, $b) { |