X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FMailing%2FBAO%2FMailing.php;h=a2b20bcf32dd27d459df3020d808f00d6876a3e6;hb=2bb8b30263fe38bebabf10f1d0497a486cb74f5c;hp=4951fe4bea9cbdbedd6bff354a4da8627b0435b0;hpb=d42861d656975793fcfe54ef36097aa602b273b3;p=civicrm-core.git diff --git a/CRM/Mailing/BAO/Mailing.php b/CRM/Mailing/BAO/Mailing.php index 4951fe4bea..a2b20bcf32 100644 --- a/CRM/Mailing/BAO/Mailing.php +++ b/CRM/Mailing/BAO/Mailing.php @@ -1080,15 +1080,18 @@ ORDER BY civicrm_email.is_bulkmail DESC elseif ($contactId === 0) { //anonymous user $contact = []; - CRM_Utils_Hook::tokenValues($contact, $contactId, $job_id); + CRM_Utils_Hook::tokenValues($contact, [$contactId], $job_id); } else { $params = [['contact_id', '=', $contactId, 0, 0]]; list($contact) = CRM_Contact_BAO_Query::apiQuery($params); + // $contact is an array of [ contactID => contactDetails ] - //CRM-4524 - $contact = reset($contact); + // also call the hook to get contact details + CRM_Utils_Hook::tokenValues($contact, [$contactId], $job_id); + // Don't send if contact doesn't exist + $contact = reset($contact); if (!$contact || is_a($contact, 'CRM_Core_Error')) { CRM_Core_Error::debug_log_message(ts('CiviMail will not send email to a non-existent contact: %1', [1 => $contactId] @@ -1098,9 +1101,6 @@ ORDER BY civicrm_email.is_bulkmail DESC $res = NULL; return $res; } - - // also call the hook to get contact details - CRM_Utils_Hook::tokenValues($contact, $contactId, $job_id); } $pTemplates = $this->getPreparedTemplates();