-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TokenProcessor - fix greetings tokens #16624
TokenProcessor - fix greetings tokens #16624
Conversation
…ause replaceContactTokens removes all 'invalid' tokens
(Standard links)
|
@mattwire can we replicate in a test? |
@mattwire This seems right. Note also that the docblock for replaceGreetingTokens() says: "::replaceContactTokens() may need to be called after this method, to replace tokens supplied from this method." - which agrees with the reordering in this PR. As you note, very little currently uses this. |
I'm going to +1 the need for some test coverage to demonstrate the greeting token scenario.
|
@eileenmcnaughton @totten @aydun It appears in some cases greetings tokens are replaced when called after Ok to merge? |
@mattwire The test looks sensible to me. Guess we've rolled a hard dice on figuring that edge-case, and I don't want to drag this out more. On the upside: even if the test doesn't reproduce the exact bug, it does still mitigate the risk of forgetting to fix greeting-tokens during a replacement of I made a small edit - when doing assertions in a loop, it helps to have some assertion outside the loop which checks the size/quantity/number of iterations. (If |
Overview
replaceGreetingsTokens must be called before replaceContactTokens because replaceContactTokens removes all 'invalid' tokens (including the
{contact.email_greeting}
etc. so they don't get replaced.Found while working on emailapi extension and tokenprocessor.
Before
Greetings tokens not replaced.
After
Greetings tokens replaced.
Technical Details
TokenCompatSubscriber is a compatibility layer between contact tokens and the new token processor. So this change only affects code that uses the tokenProcessor (which is just scheduled reminders).
Also see CRM/Core/BAO/MessageTemplate.php where it is called in the same order as this PR.
Aside, I don't understand why we have separate functions for contact greetings and contact tokens - and why replaceContactTokens can't just call replaceGreetingTokens or similar (currently it's the other way around and replaceGreetingTokens calls replaceContactTokens internally! Ugh!
Comments
@aydun any chance of a quick review so we can get this into 5.24 with all the other tokenProcessor improvements that have already gone in. @eileenmcnaughton