/**
* Get users with static caching for existing users
*
* Build anonymous fake user (with destination, send_method) for anonymous users
* We need to pass the send method to produce the right tokens later
*/
function notifications_load_user($uid, $destination = NULL, $send_method = NULL) {
if ($uid) {
return messaging_load_user($uid);
}
elseif ($destination) {
$account = drupal_anonymous_user();
$account->destination = $destination;
$account->send_method = $send_methor;
}
}
1) typo: s/$send_methor/$send_method
2) What happens if $uid is 0 and no destination is provided?
3) No return statement when $account is loaded with anonyous user.
Note that callers of notifications_load_user() expect a valid $account object, so this one needs to return an object, yes or yes. :)
Proposse fix:
function notifications_load_user($uid, $destination = NULL, $send_method = NULL) {
if ($uid) {
return messaging_load_user($uid);
}
$account = drupal_anonymous_user();
if ($destination) {
$account->destination = $destination;
}
$account->send_method = $send_method;
return $account;
}
Comments
Comment #1
markus_petrux commentedhmm... probably, there's no need to check for $destination, so how about this?
Comment #2
jose reyero commentedYes, this makes sense. Implemented your suggestion and added some explanation comments.
Thanks