From b83aa19bb29b7de0f16dcb25e8d7abeb8b10ac2f Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Fri, 13 Feb 2009 04:43:00 +0000 Subject: #370846 follow-up by catch: Fix #weight sorting in drupal_render(). --- includes/common.inc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'includes') diff --git a/includes/common.inc b/includes/common.inc index c1dc6f8f2..7b97fe67d 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -3493,11 +3493,19 @@ function element_children(&$elements, $sort = FALSE) { } } } - // Sort the element if necessary. + // Sort the children if necessary. if ($sort && $sortable) { uasort($children, 'element_sort'); + // Put the sorted children back into $elements in the correct order, to + // preserve sorting if the same element is passed through + // element_children() twice. + foreach ($children as $key => $child) { + unset($elements[$key]); + $elements[$key] = $child; + } + $elements['#sorted'] = TRUE; } - $elements['#sorted'] = TRUE; + return array_keys($children); } -- cgit v1.2.3