From f5a4f24b5e02c82f67d90116356f83a542f5b99f Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Tue, 27 Jan 2009 02:14:42 +0000 Subject: #364407 by catch: Fix drupal_render() sorting (with tests). --- includes/common.inc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'includes') diff --git a/includes/common.inc b/includes/common.inc index dd7e58c35..3e5d0c383 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -3289,12 +3289,10 @@ function drupal_render(&$elements) { } } - // Sort the elements by weight, if there are any children, and they have not - // been sorted elsewhere already, for example by a database query. Pre-sorted - // elements should have $elements['#sorted'] set to TRUE to avoid unnecessary - // calls to uasort(). - $children = !isset($elements['#children']) ? element_children($elements) : FALSE; - if (empty($elements['#sorted']) && $children) { + // Sort the elements by weight if they have not been sorted elsewhere already, + // for example by a database query. Pre-sorted elements should have + // $elements['#sorted'] set to TRUE to avoid unnecessary calls to uasort(). + if (empty($elements['#sorted'])) { uasort($elements, 'element_sort'); $elements['#sorted'] = TRUE; } @@ -3302,6 +3300,7 @@ function drupal_render(&$elements) { $content = ''; $elements += array('#title' => NULL, '#description' => NULL); if (!isset($elements['#children'])) { + $children = element_children($elements); // Render all the children that use a theme function. if (isset($elements['#theme']) && empty($elements['#theme_used'])) { $elements['#theme_used'] = TRUE; -- cgit v1.2.3