From 7558391f18636038a295c598fc8a874bcad6c932 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Tue, 5 Jan 2016 04:15:36 +0530 Subject: [PATCH] CRM-11153 fix - Custom tokens in scheduled reminders https://issues.civicrm.org/jira/browse/CRM-11153 --- Civi/Token/TokenCompatSubscriber.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Civi/Token/TokenCompatSubscriber.php b/Civi/Token/TokenCompatSubscriber.php index 152b5b7ae0..104d9f1117 100644 --- a/Civi/Token/TokenCompatSubscriber.php +++ b/Civi/Token/TokenCompatSubscriber.php @@ -49,9 +49,10 @@ class TokenCompatSubscriber implements EventSubscriberInterface { $messageTokens = $e->getTokenProcessor()->getMessageTokens(); foreach ($e->getRows() as $row) { + $contactId = $row->context['contactId']; if (empty($row->context['contact'])) { $params = array( - array('contact_id', '=', $row->context['contactId'], 0, 0), + array('contact_id', '=', $contactId, 0, 0), ); list($contact, $_) = \CRM_Contact_BAO_Query::apiQuery($params); $contact = reset($contact); //CRM-4524 @@ -70,11 +71,13 @@ class TokenCompatSubscriber implements EventSubscriberInterface { $contact = array_merge($contact, $row->context['tmpTokenParams']); } + $contactArray = !is_array($contactId) ? array($contactId => $contact) : $contact; + // Note: This is a small contract change from the past; data should be missing // less randomly. //\CRM_Utils_Hook::tokenValues($contact, $row->context['contactId']); - \CRM_Utils_Hook::tokenValues($contact, - $row->context['contactId'], + \CRM_Utils_Hook::tokenValues($contactArray, + (array) $contactId, empty($row->context['mailingJob']) ? NULL : $row->context['mailingJob']->id, $messageTokens, $row->context['controller'] -- 2.25.1