pass mailingJobId to hook_tokenValues #12026
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
Fixes bug where mailing job id was not passed to
CRM_Utils_Hook::tokenValues()
.Before
Flexmailer sets
mailingJobId
as context for the token in DefaultComposer::createTokenRowContext()TokenCompatSubscriber::onEvaluate()
should pick up the mailingJobId and pass it on toCRM_Utils_Hook::tokenValues()
, however, there is a typo on the code that prevents it passed on.After
This PR fixes the typo so that the ID is passed on correctly.
Comments
I git blamed through
Civi/Token/TokenCompatSubscriber.php
and this appears to be a typo that was not picked up yet since no one has any code that relies on the presence of mailingJobId in the token values hook (until now).At the same time, I am wondering how to be sure that
TokenCompatSubscriber::onEvaluate()
is not called by some other process that is passing a MailingJob object as the context. I don't think so, and my logic is as follows:onEvaluate
is registered as listening to\Civi\Token\Events::TOKEN_EVALUATE
\Civi\Token\TokenProcessor::evaluate()
evaluate()
is only called in one other place apart fromTokenCompatSubscriber::onEvaluate()
:CRM_Core_BAO_ActionSchedule
and mailingJob is not set/relevant hereBut maybe I missed something.