From 5f64acff73ae640d32a74c54b4f24578f85d113d Mon Sep 17 00:00:00 2001
From: David Meister <thedavidmeister@gmail.com>
Date: Thu, 6 Jun 2013 02:01:15 +1000
Subject: [PATCH] 2012818-1

---
 core/includes/common.inc | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/core/includes/common.inc b/core/includes/common.inc
index a8ad43a..dd17454 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -4987,14 +4987,13 @@ function drupal_render(&$elements) {
       $elements['#children'] .= drupal_render($elements[$key]);
     }
   }
-  // If #theme was not set, but the element has raw #markup, prepend the content
-  // in #markup to #children. #children may contain the rendered content
-  // supplied by #theme, or the rendered child elements, as processed above. If
-  // both #theme and #markup are set, then #theme is responsible for rendering
-  // the element. Eventually assigned #theme_wrappers will expect both the
-  // element's #markup and the rendered content of child elements in #children.
-  if (!isset($elements['#theme']) && isset($elements['#markup'])) {
-    $elements['#children'] = $elements['#markup'] . $elements['#children'];
+  // If the element uses #markup to define raw HTML prepend this to #children.
+  // At this point #children may contain the content rendered by theme() or
+  // recursively by drupal_render(). #theme_wrappers will expect a single string
+  // for the value of #children so we do the concatenation now to allow both
+  // #markup and #children to be wrapped.
+  if (isset($elements['#markup'])) {
+     $elements['#children'] = $elements['#markup'] . $elements['#children'];
   }
 
   // Add any JavaScript state information associated with the element.
-- 
1.7.11.1

