see: http://drupal.org/node/58714

The theme() function does not function identically under php4 and php5. It would be helpful to have this explained in the API documentation.

CommentFileSizeAuthor
#4 theme-php4-5-note_1.txt693 bytespwolanin
#1 theme-php4-5-note_0.txt577 bytespwolanin

Comments

pwolanin’s picture

Title: theme() function differences in php4 vs. php5 » Doxygen documentation for theme() function php4 vs. php5
Project: Documentation » Drupal core
Version: » x.y.z
Component: Developer Guide » theme system
Status: Active » Needs review
StatusFileSize
new577 bytes

Attached is a first attempt to document this better.

drumm’s picture

Status: Needs review » Needs work

I would like to see a notice about how theme functions should never use pass by reference in their implementations (despite apparently being possible with PHP 5). That would make code a bit unpredictable and incomaptible with 4.

pwolanin’s picture

Yes, I agree- but I wan't sure how/where to include this. Suggestions welcome.

pwolanin’s picture

StatusFileSize
new693 bytes

Ok- added more to the attached (if it's not overkill). In terms of PHP 5 behavior is that it seems all objects (like $node) are passed by reference in PHP 5. See, for example, http://www.php.net/manual/en/language.oop5.basic.php#51624

I'm new to PHP programming, but this difference between PHP 4 and PHP 5 seems like it could cause some subtle bugs if drupal code is developed on one and then used on the other?

pwolanin’s picture

Status: Needs work » Needs review

re-reading this, the wording seem good enough- any comments?

chx’s picture

Status: Needs review » Closed (won't fix)

First of all, only objects are passed by reference. And regardless of PHP version because theme() does not define any references the arguments are not taken by reference. So if you want to mention this, then specify objects in the comment but I do not think this needs commenting because it's a well known fact that PHP5 works this way. We do not need to restate PHP documentation in the comments. We only mention PHP bugs.