Contribution tokens don't render correctly
I received a bug report that indicated that a token that rendered a date wasn't localizing, and another token for an option list was showing the value, not the label (i.e. no pseudoconstant lookup). This is identical to dev/mail#46 (moved).
The fix can be done in a couple of different ways, I thought I'd check in with @jaapjansma about which is preferred, since it seems like there were some intentional decisions made here.
My preferred approach is to replace CRM_Utils_Token::replaceContributionTokens()
with CRM_Contribute_BAO_Contribution::replaceContributionTokens()
. This involves an extra API lookup, which could optionally be avoided by reordering the "subject" and "body" token resolution to happen concurrently instead of consecutively.
However, it seems Jaap went out of the way to avoid this, so I made an alternate fix where moved the construction of $messageTokens
above the contribution lookup. Then I made a call to a wrapper function around the Contribution API that resolved these tokens correctly.
I see a similar problem in CRM_Pdfapi_PDF::sendPdf()
but the code is a little trickier there. If you give me feedback about reasons to prefer one approach, I'll try to fix it in the other places.