drupal_render misses some code from previous commit. Node preview is rendered twice for instance
swentel - August 14, 2008 - 20:45
| Project: | Drupal |
| Version: | 7.x-dev |
| Component: | node system |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed |
Description
Fresh install from head.
1) click add page or article and fill in title and body
2) click preview. normally, you only should see the preview appearing once
3) instead, it appeared twice
Haven't looked why this is happening, will try and come up with a patch following days.

#1
Can't really get my head on this. Attaching a screenshot. You see the preview div twice in the HTML. Maybe someone else knows what goes wrong here.
#2
http://drupal.org/node/252013
-- $previous = array();
- foreach (array('#value', '#type', '#prefix', '#suffix') as $key) {
- $previous[$key] = isset($elements[$key]) ? $elements[$key] : NULL;
- }
// If we rendered a single element, then we will skip the renderer.
if (empty($children)) {
$elements['#printed'] = TRUE;
}
else {
- $elements['#value'] = '';
+ $elements['#markup'] = '';
}
- $elements['#type'] = 'markup';
-
+
unset($elements['#prefix'], $elements['#suffix']);
$content = theme($elements['#theme'], $elements);
-
- foreach (array('#value', '#type', '#prefix', '#suffix') as $key) {
- $elements[$key] = isset($previous[$key]) ? $previous[$key] : NULL;
- }
Removing the foreaches copying #prefix and #suffix is the cause; calls to drupal_render($form) in the form's theme function _also_ render the prefix (inside the form).
#3
Background for the foreaches: http://drupal.org/node/100787. History repeating... :)
#4
Patch adds the foreach again. #value is left out as said by Heine on irc. Please review, very annoying bug imo :)
Kudos to Heine!
#5
(just changing title and bumping to critical just to get more attention as this patch deserves that I think)
#6
Tested, patch works for me.
#7
Patch applies cleanly, corrects the bug. Looking at the historical issue, the implementation is the same, so there shouldn't be any code issues. Node SimpleTests run successfully.
#8
Committed to CVS HEAD.
temp
Automatically closed -- issue fixed for two weeks with no activity.
#9
Automatically closed -- issue fixed for two weeks with no activity.