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.
Object's are passed by reference by default, so there's no need to state that the first parameter to webform_node_view() is a reference.
In fact, doing so displays the following warning:
Warning: Parameter 1 to webform_node_view() expected to be a reference, value given in module_invoke_all() (line 708 of www/includes/module.inc).
Comment | File | Size | Author |
---|---|---|---|
#4 | hook-parameters-765308-4.patch | 983 bytes | JohnAlbin |
#1 | hook-node-view-765308-1.patch | 424 bytes | JohnAlbin |
Comments
Comment #1
JohnAlbinHere's the patch.
Comment #2
quicksketchWhile true, it sounds like something is being passed into webform_node_view() that cannot be passed by reference at all (such as NULL) which is causing that error. Manually specifying the ampersand may not be necessary, but it shouldn't be causing such a warning.
Comment #3
JohnAlbinThis turns out part of a bigger problem. On a clean CVS install with PHP 5.3.1, when I try to add a component to a webform-enabled node type, I get the following failure:
And when just viewing a node of that type I get:
Ah, crap. I just discovered its a bug in PHP 5.3.1. http://bugs.php.net/bug.php?id=50394 That explains the "expected to be a reference, value given" part of the warning.
I still think webform shouldn't be using & in the params for those two hooks, but I can't really test a fix on this broken PHP 5.3.1 system. (which, btw, is the default PHP on the Mac OS X 10.6.3.)
Comment #4
JohnAlbinWhoops. The PHP bug is critical. Can't tell the severity of the webform bug.
Here's a patch.
Comment #5
JohnAlbinNeeds review!
Comment #6
quicksketchI still can't telly why this is necessary or reproduce any problems with the current approach. Could you provide any way to reproduce an error?
Comment #7
Stevel CreditAttribution: Stevel commentedI've reproduced this bug with 7.x-3.0-beta5, and drupal 7 beta 5. The PHP-version is 5.3.2, the default version in the latest Ubuntu LTS version. I got the same as in #3. The patch provided in #4 solves the problems as far as I can tell.
I also agree that apart from this php error, the two mentioned hooks shouldn't use the & as per http://api.drupal.org/api/function/hook_node_load/7 and http://api.drupal.org/api/function/hook_node_view/7
Comment #8
Stevel CreditAttribution: Stevel commentedComment #9
quicksketchAh well, even though I'd argue these changes are 100% unnecessary and indicative of a larger problem with either the implementation around Webform or (in this case apparently) directly with PHP. The & shouldn't make any difference at all.
But as is these lines are changed anyway between the D6 and D7 versions so I can't really make a claim for consistency between branches. Committed to D7 branch.