Download & Extend

drupal_render misses some code from previous commit. Node preview is rendered twice for instance

Project:Drupal core
Version:7.x-dev
Component:node system
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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.

Comments

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

AttachmentSizeStatusTest resultOperations
preview_node_twice.png31.21 KBIgnored: Check issue status.NoneNone

#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

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!

AttachmentSizeStatusTest resultOperations
prefix_not_unset.patch1.09 KBIgnored: Check issue status.NoneNone

#5

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

Tested, patch works for me.

#7

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

Status:reviewed & tested by the community» fixed

Committed to CVS HEAD.

temp

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

#9

Status:fixed» closed (fixed)

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

nobody click here