JMAConsulting / biz.jmaconsulting.mte

Mandrill Emails Extension for CiviCRM
10 stars 21 forks source link

ignore first alter call for messageTemplate #120

Closed konadave closed 2 years ago

konadave commented 2 years ago

https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterMailParams/#:~:text=Note%20that%20this%20hook%20is%20called%20twice%20when%20sending%20a%20message%20template%2C%20once%20early%20in%20the%20message%20generation%20(before%20tokens%20are%20applied%2C%20with%20the%20context%20messageTemplate)%20and%20then%20later%20from%20CRM_Utils_Mail%3A%3Asend()%20with%20the%20context%20singleEmail

I don't know if calling alterMailParams() twice is new behavior, or if the contents for $params has changed when context == messageTemplate. If alterMailParams() runs in this context, it ultimately fails trying to create a mailing event queue without a contact ID, and no message is sent or activities created. Ignoring this context solves the problem.

Edzelopez commented 2 years ago

@monishdeb can you please review this PR?

JoeMurray commented 2 years ago

@monishdeb ping

monishdeb commented 2 years ago

It works for me. Thanks for the patch @konadave