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.

CommentFileSizeAuthor
#4 prefix_not_unset.patch1.09 KBswentel
#1 preview_node_twice.png31.21 KBswentel

Comments

swentel’s picture

StatusFileSize
new31.21 KB

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.

heine’s picture

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).

heine’s picture

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

swentel’s picture

Status: Active » Needs review
StatusFileSize
new1.09 KB

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

swentel’s picture

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)

AmrMostafa’s picture

Tested, patch works for me.

obsidiandesign’s picture

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.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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