Call-time-pass-by-reference errors/warnings introduced into converted code

girishmuraly - September 7, 2009 - 11:13
Project:Coder
Version:6.x-1.0
Component:Code
Category:bug report
Priority:minor
Assigned:Unassigned
Status:active
Description

When converting code from Drupal 5 to Drupal 6, call-time-pass-by references of the form function_name(&$var) are introduced in the function call.

For example, in my hook_submit, coder converts the function definition from: function mymodule_submit($form_id, $form_values){} to: function mymodule_submit($form, &$form_state){} which is fine.
But the same substitutions are performed on the function call as well. So my call to the above function also gets converted to mymodule_submit($form, &$form_state);/code> which introduces a Call-time-pass-by-reference Warning if you have <code>allow_call_time_pass_reference = Off in your php.ini

The fix:
Is there a way of altering the substition being performed based on if its a function definition vs. a function call? Call-time pass-by-reference has been deprecated.

#1

girishmuraly - September 9, 2009 - 09:18

Actually I realized the fallacy in my example above.

What coder does is it treats any _submit() functions as a 'hook_submit()' and performs the substitution treatments. If in fact it was a hook_submit(), then its valid to assume that that pattern string would only appear in a function definition, as we would not explicitly call a hook_submit() in modules. However, Coder is falsely recognizing any _submit() functions as a hook_submit, thereby causing havoc in the form definition substitutions as well as function calls to the same.

 
 

Drupal is a registered trademark of Dries Buytaert.