webform has some functions that take &$node as a by-reference argument. This is bad for two reasons:
- $node is an object. No need to pass it as a reference. It can even have undesired side effects to do so.
- The respective functions are called from form.inc, via call_user_func_array(). Typically, the arguments given to the call_user_func_array in form.inc are not by-reference. This makes a warning message in PHP 5.3.
PHP 5.3 is a bitch, but in this case, it's only logical to fix the respective functions.
Fixing the functions is easy, just remove the "&" in the argument list.
Functions that need to be fixed:
- webform_components_form($form_state, &$node)
- webform_client_form($form_state, &$node, $submission, $enabled = FALSE, $preview = FALSE)
- maybe others, I don't know.
Comments
Comment #1
donquixote commentedEDIT:
At the time I created this issue I didn't know much about PHP 4. Fact is, PHP 4 needs objects passed explicitly by reference. or otherwise it will clone the object.
The issue needs to be taken care of, but it's not that simple.
Comment #2
drasgardian commentedI ran into this issue using the latest stable release (6.x-2.7) and php 5.3.
Corrected by removing the "&" from the arguments lists of
webform_client_form($form_state, &$node, $submission, $enabled = FALSE, $preview = FALSE)
and
webform_component_edit_form($form_state, &$node, $component, $clone = FALSE)
I didn't need to change webform_components_form($form_state, &$node) - I guess the "&" must have been added to that in 6.x-3.x-dev
Comment #3
emscene commentedThanks this worked for me. I had downgraded the php already to 5.2.8, but I have Drupal 6.14, maybe that was giving me trouble.
The webform_client_form($form_state, &$node, $submission, $enabled = FALSE, $preview = FALSE) you can find in modules/webform/webform.module
and webform_component_edit_form($form_state, &$node, $component, $clone = FALSE) you can find in modules/webform/webform_components.inc
Comment #4
berdirThe correct way to fix these messages while keeping PHP 4 compatibility is to change the caller of those functions.
This is possible by telling call_user_func_array() which params are by-reference by assigning them with a & to the passed array. See http://api.drupal.org/api/function/drupal_execute/6 for an example (the line "$args[1] = &$form_state;").
Comment #5
quicksketchJust a note that these problems have already been fixed in #588234: Webform causes error in PHP 5.3. We did not need $node to be passed in by reference in either situation, since we were not modifying it.