Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.1.1
-
Fix Version/s: 4.2.0
-
Component/s: CiviMember
-
Labels:
Description
Some tokens are replaced with blank values in the membership email reminders automatically sent via the Job scheduler, while some others are replaced fine. This happens at least with the standard
{contact.email_greeting}token, as well as with all tokens defined via the hook system. When an email is sent as an activity to the same contact(s), using the same template as the email reminder all token replacements are done perfectly.
I noticed the token replacement code seem very different in both cases:
- the token replacements for email reminders is done in the CRM_Core_BAO_MessageTemplates::sendReminder function
- it uses CRM_Mailing_BAO_Mailing::getTokens to identify tokens to be replaced
- it replaces the token values from a call to CRM_Contact_BAO_Query::apiQuery
- the token replacements for emails sent as activities is done in the CRM_Activity_BAO_Activity::sendEmail function
- it uses CRM_Utils_Token::getTokens to identify tokens to be replaced
- it replaces the token values from a call to CRM_Utils_Token::getTokenDetails
I therefore recreated the token identification and replacement code in the CRM_Core_BAO_MessageTemplates::sendReminder using the code from CRM_Activity_BAO_Activity::sendEmail. I tested it with both standard tokens and tokens defined via the hook system and it works perfectly now - all tokens are replaced with the correct values.
Attached is the corresponding patch for file CRM/Core/BAO/MessageTemplates.php