Closed (fixed)
Project:
Webform
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
8 Apr 2010 at 06:56 UTC
Updated:
2 Jul 2010 at 02:00 UTC
Jump to comment: Most recent file
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 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 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.