diff --git a/core/includes/common.inc b/core/includes/common.inc index 2048ab4..051fbe8 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -3822,6 +3822,20 @@ function drupal_render(&$elements) { return ''; } + // Call drupal_render_children() instead of drupal_render() to prevent + // recursion if the special '#render_children' key is set (in all instancecs + // except for the $page array). + if (isset($elements['#render_children']) && $elements['#theme'] != 'page') { + $children_keys = element_children($elements); + $output = ''; + foreach ($children_keys as $key) { + if (!empty($elements[$key])) { + $output .= drupal_render($elements[$key]); + } + } + return $output; + } + // Do not print elements twice. if (!empty($elements['#printed'])) { return ''; @@ -3868,10 +3882,8 @@ function drupal_render(&$elements) { $theme_is_implemented = isset($elements['#theme']); // Call the element's #theme function if it is set. Then any children of the - // element have to be rendered there. If the internal #render_children - // property is set, do not call the #theme function to prevent infinite - // recursion. - if ($theme_is_implemented && !isset($elements['#render_children'])) { + // element have to be rendered there. + if ($theme_is_implemented) { $elements['#children'] = theme($elements['#theme'], $elements); // If theme() returns FALSE this means that the hook in #theme was not found