For the sms send function there is an infinite loop. When calling the module implements sms_send piece the messaging module is one of the modules. The messaging sms module re-calls the sms_send function and the loop continues. This then exhausts the function. Need to look at the recursion for that and make sure that the sms_send function is not called recursively.
function sms_send($number, $message, $options = array()) {
$gateway = sms_default_gateway();
foreach (module_implements('sms_send') as $module) {
if ($module == 'messaging') { continue; }
$function = $module .'_sms_send';
$function($number, $message, $options, $gateway);
}
if (function_exists($gateway['send'])) {
$response = $gateway['send']($number, $message, $options);
}
return sms_handle_result($response, $number, $message);
}
For the current time on our site i added a check for the messaging module and continue if it is there, however this is not a good fix, will need to investigate how that is occurring and why. Possibly have the messaging sms module be smarter and take in the calling function, if it is the sms_send function then we do not call it since it is already being called?
Comments
Comment #1
darren.ferguson commentedHaving thought it over would it make sense to modify the messaging_sms_send function. We could pass in the params array a boolean i.e. call_send or some other name. Should default to true in the params list array and if we decide to set it to false then it will not call the sms_send function from the messaging and any other module that should implement the hook.
Would that be an acceptable patch for the issue?
/**
* Send message to multiple destinations
*
* This is just a wrapper for sms_send()
*/
function messaging_sms_send($destination, $message, $params = array('call_send' => true)) {
// This function takes an array of destinations so
if ($params['call_send']) {
return sms_send(array($destination), $message['subject'].$message['body']);
}
}
Above is how the function in messaging_sms would look.
The corresponding call from sms_send would just add to the options array call_send
function sms_send($number, $message, $options = array()) {
$gateway = sms_default_gateway();
$options['call_send'] = true; // setting so we do not recursively re-call this function.
foreach (module_implements('sms_send') as $module) {
$function = $module .'_sms_send';
$function($number, $message, $options, $gateway);
}
if (function_exists($gateway['send'])) {
$response = $gateway['send']($number, $message, $options);
}
return sms_handle_result($response, $number, $message);
}
Comment #2
Will White commentedI believe this is an issue with the messaging module, although it was caused by the recent addition of hook_sms_send() to the SMS Framework. messaging_sms_send() was never meant to treated as an implementation of that hook. The messaging module simply needs to rename the messaging_sms_send() function to avoid this namespace collision.
Or, I would be open to suggestions for renaming hook_sms_send().
Thanks for the report Darren.
Comment #3
darren.ferguson commentedWill
Thanks for the update, would think that changing the messaging module is probably not a good idea since i think the messaging_sms_send is in the format that is users i.e. messaging_email_send, etc.
Would you be open to renaming the hook hook_sms_pre_send since it is doing pre-processing before the actual sending of the sms message??
I think that would resolve the issue satisfactorily since the module relying on this would be easy to change.
Your call though, i have no problems which ever way you decide to go.
Comment #4
jose reyero commentedIt looks like we should rename the messaging_sms send function
So moving this issue to the messaging module
Btw, this _sms_send() hook is only for Drupal 6 version?
Comment #5
jose reyero commentedThere seems to be more collisions with other packages (and I guess sms framework and send module will clash too)
See also http://drupal.org/node/294322
Comment #6
jose reyero commentedRenamed all that functions, should work now.
Comment #7
darren.ferguson commentedJose
thank you for fixing the issue.
Comment #8
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.