Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#13 | drupal-render-printed-D6.patch | 1.19 KB | rdrh555 |
#7 | drupal-render-printed-357799-1220662.patch | 1.15 KB | cfennell |
Comments
Comment #1
kenorb CreditAttribution: kenorb commentedWhy is that?
It's a bug!
http://drupal.org/node/346264#comment-1220620
http://drupalbin.com/1059
Comment #2
Heine CreditAttribution: Heine commented@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:
Comment #3
kenorb CreditAttribution: kenorb commentedWhen 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;/
Comment #4
Heine CreditAttribution: Heine commentedPlease keep the issue focussed on the API documentation.
Comment #5
jhodgdonWell, 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.
Comment #6
jhodgdonAdding a short note (see #5) seems like a good Novice project
Comment #7
cfennell CreditAttribution: cfennell commentedHere's a patch that adds documentation to reflect @Heine's comment (#2) about the '#printed' flag.
Comment #8
cwgordon7 CreditAttribution: cwgordon7 commentedLooks nice, thanks! This is rtbc. :)
Comment #9
webchickThis is a nice clarification. Committed to HEAD. Thanks!
Comment #10
cfennell CreditAttribution: cfennell commentedThanks, glad to help :)
Comment #11
jhodgdonThis change needs to be ported to the D6 doc as well.
Comment #12
rdrh555 CreditAttribution: rdrh555 commentedPatch to be completed today
Comment #13
rdrh555 CreditAttribution: rdrh555 commentedHere it is
Comment #14
jhodgdonThanks! This patch applies cleanly and looks good to me. Congratulations rdrh555 on (I think) your first core patch!
Comment #15
Gábor HojtsyThanks, committed.