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

(dev/core#2947) Tokens - Auto-enable {event.*} if participantId is present #22046

Merged
merged 2 commits into from
Nov 12, 2021

Conversation

totten
Copy link
Member

@totten totten commented Nov 12, 2021

Overview

This patch addresses bug report https://lab.civicrm.org/dev/core/-/issues/2947 by revisiting some elements #21821.

CC @eileenmcnaughton @magnolia61

Before

  • When generating a PDF for a participants, the {event.*} tokens don't work.
  • The {event.*} and {participant.*} tokens key off of independent inputs ($context['eventId'] and $context['participantId']). Only participantId is supplied for the PDF.

After

  • When generating a PDF for a participants, the {event.*} tokens do work.
  • The {event.*} and {participant.*} tokens may key off of independent inputs ($context['eventId'] and $context['participantId']). However, if eventId is omitted, it will be filled automatically based on participantId.

Technical Details

This is roughly similar to how participant PDFs worked in some of the 5.43.alpha1 revisions (ie before #21821), although the implementation is slightly different. To my reading, it's a bit more thorough... e.g. it fills eventId during both civi.token.list and civi.token.eval; e.g. it supplies the eventId as part of the context so that it's available to any other listeners that consume eventId.

Adds test coverage.

@civibot
Copy link

civibot bot commented Nov 12, 2021

(Standard links)

@civibot civibot bot added the master label Nov 12, 2021
@totten totten changed the base branch from master to 5.44 November 12, 2021 01:12
@civibot civibot bot added 5.44 and removed master labels Nov 12, 2021
@eileenmcnaughton
Copy link
Contributor

thanks @totten - I'll give a spin once tests pass on the demo site & then merge if r-run passes there

The prior commit means that `$context['participantId']` will activate `{event.*}` tokens - in contexts
that use `TokenProcessor`. And the `TokenProcessor` is *somewhat* matched to the older functions.

This twiddles the match-up:

* Provide continuity for the deprecated `CRM_Core_SelectValues::participantTokens()` - so it still
  only returns `{participant.*}` tokens. Borrow the technique which excludes `{domain.*}` tokens.
  This should ensure better continuity for any callers that actually use `CRM_Utils_Token`.

* Update the assertions for the `TokenProcessor` to show that the `{event.*}` tokens are presented in
  participant-related contexts.
@seamuslee001
Copy link
Contributor

Jenkins re test this please

@eileenmcnaughton
Copy link
Contributor

I just did an r-run on 5.43 & it worked

@seamuslee001 seamuslee001 merged commit 5d5b2c0 into civicrm:5.44 Nov 12, 2021
@totten totten deleted the 5.44-eventid branch November 12, 2021 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants