drupal_render($function()) causes strict warnings

alpritt - July 5, 2009 - 00:41
Project:Drupal
Version:7.x-dev
Component:other
Category:bug report
Priority:normal
Assigned:Unassigned
Status:duplicate
Description

This construct...

drupal_render(drupal_get_form('some_form'))

... is causing a bunch of strict warnings.

#1

alpritt - July 5, 2009 - 07:15
Title:Strict warning: Only variables should be passed by reference» drupal_render($function()) causes strict errors

From http://drupal.org/node/353069#comment-1552904 where this was introduced:

We should *not* be using drupal_render() in module code. Modules need to pass back arrays, not strings. There are very few legitimate uses for drupal_render() beyond drupal_render_page(). Just a few theme functions that need to ccarefully control their output. I added some drupal_render() calls because refactoring spaghetti like comment module is beyond the scope of this patch. I'll do it, but not here.

So a patch for this issue needs to fix code that *does* require drupal_render() (such as in install.php), and then make sure we have issues for fixing other occurrences The Right Way.

#2

alpritt - July 5, 2009 - 07:14
Title:drupal_render($function()) causes strict errors» drupal_render($function()) causes strict warnings

Being pedantic.

#3

alpritt - July 5, 2009 - 07:23

eh, I shouldn't rely on issues titles to describe bugs properly. Sample message:

Strict Standards: Only variables should be passed by reference in /Users/alanpritt/Sites/htdocs/head_headtpl3diff/install.php on line 435

#4

mfb - July 24, 2009 - 15:07

See also #348448: PHP strict warnings when running tests which fixes all the drupal_render() calls (if not The Right Way).

#5

mfb - October 12, 2009 - 17:31
Status:active» duplicate

Let's resolve this in #348448: PHP strict warnings when running tests

 
 

Drupal is a registered trademark of Dries Buytaert.