Skip to content
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

pass mailingJobId to hook_tokenValues #12026

Conversation

michaelmcandrew
Copy link
Contributor

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 to CRM_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
  • the only place this event is dispatched is in \Civi\Token\TokenProcessor::evaluate()
  • evaluate() is only called in one other place apart from TokenCompatSubscriber::onEvaluate(): CRM_Core_BAO_ActionSchedule and mailingJob is not set/relevant here

But maybe I missed something.

@michaelmcandrew michaelmcandrew changed the title pass the mailing job id to hook token values pass mailingJobId to hook_tokenValues Apr 24, 2018
@seamuslee001
Copy link
Contributor

ping @totten

@eileenmcnaughton
Copy link
Contributor

@totten this appears to be just a fix for a typo of yours but not really comfortable merging without your check

@eileenmcnaughton eileenmcnaughton added the sig:extension support Supports being able to integrate extensions with CiviCRM label Jun 9, 2018
@michaelmcandrew
Copy link
Contributor Author

@totten - ping again :)

@eileenmcnaughton
Copy link
Contributor

I'm gonna merge this - when the original submitter comes back to a minor code change after a long spell and still thinks it is correct I think they can qualify as an independent reviewer. This seems pretty minor & clear cut & safe from what I can see & we can't clone @totten so we have to work within the tottens we have

@eileenmcnaughton eileenmcnaughton merged commit a215c54 into civicrm:master Aug 3, 2018
@michaelmcandrew
Copy link
Contributor Author

thanks @eileenmcnaughton - i kind of regretted adding another ping @totten to the see of ping @tottens after I had done it since, yes, we do have to find a way to expand the tims. I'll be more imaginative next time :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
master sig:extension support Supports being able to integrate extensions with CiviCRM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants