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

swentel - August 15, 2008 - 10:56

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.

AttachmentSize
preview_node_twice.png 31.21 KB

#2

Heine - August 15, 2008 - 21:29

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

Heine - August 15, 2008 - 21:34

Background for the foreaches: http://drupal.org/node/100787. History repeating... :)

#4

swentel - August 15, 2008 - 21:41
Status:active» needs review

Patch adds the foreach again. #value is left out as said by Heine on irc. Please review, very annoying bug imo :)
Kudos to Heine!

AttachmentSize
prefix_not_unset.patch 1.09 KB

#5

swentel - August 15, 2008 - 21:45
Title:Node preview is rendered twice.» drupal_render misses some code from previous commit. Node preview is rendered twice for instance
Priority:normal» critical

(just changing title and bumping to critical just to get more attention as this patch deserves that I think)

#6

alienbrain - August 15, 2008 - 23:37

Tested, patch works for me.

#7

obsidiandesign - August 16, 2008 - 04:00
Status:needs review» reviewed & tested by the community

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

Dries - August 16, 2008 - 07:33
Status:reviewed & tested by the community» fixed

Committed to CVS HEAD.

temp

Anonymous (not verified) - August 30, 2008 - 07:43

Automatically closed -- issue fixed for two weeks with no activity.

#9

Anonymous (not verified) - August 30, 2008 - 07:51
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.