Hello,
I have several logic hooks working well on SuiteCRM 7.1.x.
Upgraded to 7.6.1 and then to 7.6.2, and noticed that my logic hooks functions stopped working because they do not receive parameters anymore. Saw this on Apache error logs:
[Fri May 13 16:29:39.909505 2016] [:error] [pid 5258] [client ::1:54059] PHP Warning: Missing argument 1 for FormataTelefone::formataTelefone(), called in /var/www/html/dev/include/utils/LogicHook.php on line 260 and defined in /var/www/html/dev/custom/modules/FormataTelefone_LogicHook.php on line 27, referer: http://localhost:8000/dev/index.php?action=DetailView&module=Accounts&record=bf1b4121-c180-760b-c078-5735d8571d95&return_module=Accounts&return_action=DetailView&offset=1
[Fri May 13 16:29:39.909545 2016] [:error] [pid 5258] [client ::1:54059] PHP Warning: Missing argument 2 for FormataTelefone::formataTelefone(), called in /var/www/html/dev/include/utils/LogicHook.php on line 260 and defined in /var/www/html/dev/custom/modules/FormataTelefone_LogicHook.php on line 27, referer: http://localhost:8000/dev/index.php?action=DetailView&module=Accounts&record=bf1b4121-c180-760b-c078-5735d8571d95&return_module=Accounts&return_action=DetailView&offset=1
[Fri May 13 16:29:39.909562 2016] [:error] [pid 5258] [client ::1:54059] PHP Warning: Missing argument 3 for FormataTelefone::formataTelefone(), called in /var/www/html/dev/include/utils/LogicHook.php on line 260 and defined in /var/www/html/dev/custom/modules/FormataTelefone_LogicHook.php on line 27, referer: http://localhost:8000/dev/index.php?action=DetailView&module=Accounts&record=bf1b4121-c180-760b-c078-5735d8571d95&return_module=Accounts&return_action=DetailView&offset=1
Scanning around line 260 of include/utils/LogicHook.php, discovered an βifβ that tests if the Class name is equal to the Function name and if itβs not then calls the function without parameters:
[b]if($hook_class == $hook_function)[/b]{
if(isset($GLOBALS['log'])){
$GLOBALS['log']->debug('Creating new instance of hook class '.$hook_class.' with parameters');
}
if(!is_null($this->bean))
$class = new $hook_class($this->bean, $event, $arguments);
else
$class = new $hook_class($event, $arguments);
}[b]else[/b]{
if(isset($GLOBALS['log'])){
$GLOBALS['log']->debug('[b]Creating new instance of hook class '.$hook_class.' without parameters[/b]');
}
$class = new $hook_class();
if(!is_null($this->bean))
$class->$hook_function($this->bean, $event, $arguments);
else
$class->$hook_function($event, $arguments);
}
If I rewrite Class and Function to the use the same names, works OK.
Apparently the code didnβt change from 7.1.x versions to 7.6.x, so maybe itβs something about upstream files calling this?
Could someone point me out to the right direction?
Thanks in advance.