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

Fix token regression - re-add support for empty tokens #21756

Merged
merged 2 commits into from
Oct 8, 2021

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Oct 7, 2021

Overview

Fix token regression - re-add support for empty tokens since this was originally being accessed from replaceGreetingTokens which is no longer called by tokenCompatSubscriber

Before

{contact.first_name}{ }{contact.last_name} leaves in { }

After

{contact.first_name}{ }{contact.last_name} removes { }

Technical Details

I originally thought the behaviour was to remove those tokens when there was a string either side - the tests show that not to be working for replaceGreetingTokens - this syncs the behaviour of the 2 rather than trying to improve it.

Comments

@totten @colemanw note this test specifically covers the 2 variants of prefix_id - but won't pass without #21705 merged

@civibot
Copy link

civibot bot commented Oct 7, 2021

(Standard links)

@civibot civibot bot added the master label Oct 7, 2021
@eileenmcnaughton eileenmcnaughton changed the title Fix token regression - re-add support for empty tokens Fix token regression - re-add support for empty tokens [tests need #21705] Oct 7, 2021
@colemanw
Copy link
Member

colemanw commented Oct 7, 2021

retest this please

@eileenmcnaughton eileenmcnaughton changed the title Fix token regression - re-add support for empty tokens [tests need #21705] Fix token regression - re-add support for empty tokens Oct 7, 2021
@eileenmcnaughton
Copy link
Contributor Author

@totten @colemanw we can merge this as is for parity but I think the before & after are not working as well as I thought - there is still a double space when middlename is empty. I suspect it's clever enough for some cases but not others

$variants = [
[
'string' => '{contact.individual_prefix}{ }{contact.first_name}{ }{contact.middle_name}{ }{contact.last_name}{ }{contact.individual_suffix}',
'expected' => 'Mr. Anthony Anderson II',
Copy link
Member

@totten totten Oct 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so your hesitation is that this produces a double-space? Which would be invisible on most HTML outputs - but visible on text outputs?

I think if this produces the same output on 5.42, then I wouldn't worry about it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied+trimmed the test to try it on 5.41. Same result with two spaces (for both TokenProcessor and replaceGreetingTokens()).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @totten

@totten
Copy link
Member

totten commented Oct 8, 2021

jenkins, test this please

1. You don't need to call evaluate() twice. It should be once after filling both rows+messages.
2. Add messages to clarify assertions
@totten
Copy link
Member

totten commented Oct 8, 2021

I had some issues where testOddTokens didn't pass when I ran the branch locally, but I think that was because of the relative-order-of-operations with the prior PR. (They started passing when I did a local rebase.) So if testOddTokens is good on the next run, then merge it.

@eileenmcnaughton eileenmcnaughton merged commit 617345f into civicrm:master Oct 8, 2021
@eileenmcnaughton eileenmcnaughton deleted the tt branch October 8, 2021 10:24
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