drupal_render api documentation (http://api.drupal.org/api/function/drupal_render/6) should state that calling the function twice returns NULL the second time. Its not clear from the documentation.

Comments

kenorb’s picture

heine’s picture

@kenorb, if you believe this is a bug (and I do not), please file a bug report against code.

While the drupal_render api documentation might state "Calling this function twice returns NULL the second time.", I do not believe that to be useful. The key feature of drupal_render (and also responsible for this behaviour) is that drupal_render marks whatever it rendered as "printed", and does not process "printed" elements again.

This is a VERY useful feature as you can do this, without having $item['somepart'] rendered twice:

$output = drupal_render($item['somepart']); // renders only $item['somepart].
$output .= drupal_render($item);  // renders the REST of $item.
kenorb’s picture

When you making some patch, how do you know how many times drupal_render has been called?
Look at this patch: http://drupal.org/files/issues/simplenews_template.module.patch (at the end)
Question: How many?
Because I don't know;/

heine’s picture

Please keep the issue focussed on the API documentation.

jhodgdon’s picture

Version: 6.x-dev » 7.x-dev

Well, probably drupal_render() should mention how it modifies its input, rather than just saying don't call it twice (i.e. say why).

Please start with Drupal 7.

jhodgdon’s picture

Issue tags: +Novice

Adding a short note (see #5) seems like a good Novice project

cfennell’s picture

Status: Active » Needs review
StatusFileSize
new1.15 KB

Here's a patch that adds documentation to reflect @Heine's comment (#2) about the '#printed' flag.

cwgordon7’s picture

Status: Needs review » Reviewed & tested by the community

Looks nice, thanks! This is rtbc. :)

webchick’s picture

Status: Reviewed & tested by the community » Fixed

This is a nice clarification. Committed to HEAD. Thanks!

cfennell’s picture

Thanks, glad to help :)

jhodgdon’s picture

Version: 7.x-dev » 6.x-dev
Status: Fixed » Patch (to be ported)

This change needs to be ported to the D6 doc as well.

rdrh555’s picture

Assigned: Unassigned » rdrh555

Patch to be completed today

rdrh555’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new1.19 KB

Here it is

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Thanks! This patch applies cleanly and looks good to me. Congratulations rdrh555 on (I think) your first core patch!

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed.

Status: Fixed » Closed (fixed)
Issue tags: -Novice

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