diff --git a/core/includes/common.inc b/core/includes/common.inc index f954b20..04305bf 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -3801,6 +3801,17 @@ function drupal_render(&$elements) { return ''; } + // If the special '#render_children' key is set, call drupal_render_children() + // instead of drupal_render() to prevent recursion. + if (isset($elements['#render_children'])) { + $children_keys = element_children($elements); + $output = ''; + foreach ($children_keys as $key) { + $output .= drupal_render($element[$key]); + } + return $output; + } + // Do not print elements twice. if (!empty($elements['#printed'])) { return ''; @@ -3850,7 +3861,7 @@ function drupal_render(&$elements) { // 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'])) { + if ($theme_is_implemented) { $elements['#children'] = theme($elements['#theme'], $elements); // If theme() returns FALSE this means that the hook in #theme was not found @@ -3862,7 +3873,7 @@ function drupal_render(&$elements) { // If #theme is not implemented or #render_children is set and the element has // an empty #children attribute, render the children now. This is the same // process as drupal_render_children() but is inlined for speed. - if ((!$theme_is_implemented || isset($elements['#render_children'])) && empty($elements['#children'])) { + if ((!$theme_is_implemented) && empty($elements['#children'])) { foreach ($children as $key) { $elements['#children'] .= drupal_render($elements[$key]); } @@ -3898,7 +3909,7 @@ function drupal_render(&$elements) { // assets otherwise. // If the internal #render_children property is set, do not call the // #theme_wrappers function(s) to prevent infinite recursion. - if (isset($elements['#theme_wrappers']) && !isset($elements['#render_children'])) { + if (isset($elements['#theme_wrappers'])) { foreach ($elements['#theme_wrappers'] as $key => $value) { // If the value of a #theme_wrappers item is an array then the theme hook // is found in the key of the item and the value contains attribute