Fix event custom field tokens in scheduled reminders #21374
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Fix for rendering Event custom field tokens like {event.custom_123} in scheduled reminders for events
Before
The token processor looks up the value for the custom field using participant id rather than event id.
Generally this will be out of range and so the Scheduled Reminder job fails with
Finished execution of Send Scheduled Reminders with result: Failure, Error message: Expected one Event but found 0
[I suppose it's possible it might hit a custom value from a random event in the co-incidence that participant_id matches some other event_id.]
After
{event.custom_123} tokens work as expected.
Technical Details
The line looks like a generalised look up for custom fields on $entity ( which is relevant when repeated in e.g.
civicrm-core/CRM/Member/Tokens.php
Line 88 in 41c0455
Comments
Looks like there are ambitious plans for TokenProcessor more generally, but hopeful this tiny fix could be useful in the interim.