diff --git a/core/includes/common.inc b/core/includes/common.inc index d0a538e..06550a4 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -3677,20 +3677,27 @@ function drupal_prepare_page($page) { /** * @needsdoc */ -function drupal_build(&$elements) { - if (isset($elements['#build'])) { - foreach ($elements['#build'] as $callable) { +function drupal_pre_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']); + } + + if (isset($elements['#pre_render'])) { + foreach ($elements['#pre_render'] as $callable) { $elements = call_user_func($callable, $elements); } // Once the item is built, the callback is no longer needed. - unset($elements['#build']); + unset($elements['#pre_render']); } // Build the child elements as well. if ($children = element_children($elements)) { foreach ($children as $child) { - drupal_build($elements[$child]); + $elements[$child] = drupal_pre_render($elements[$child]); } } + return $elements; } /** @@ -3878,25 +3885,11 @@ function drupal_render(&$elements, $is_recursive_call = FALSE) { } } - // If element building has been postponed with #build callbacks, invoke them - // now before rendering starts. - if (!$is_recursive_call) { - drupal_build($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']); - } - // 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 // element is rendered into the final text. - if (isset($elements['#pre_render'])) { - foreach ($elements['#pre_render'] as $callable) { - $elements = call_user_func($callable, $elements); - } + if (!$is_recursive_call) { + $elements = drupal_pre_render($elements); } // Allow #pre_render to abort rendering.