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#2344 unit test for fix regression affecting sending thank you letters when grouped #19481

Merged
merged 1 commit into from
Feb 1, 2021

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Feb 1, 2021

Overview

dev/core#2344 fix regression affecting sending thank you letters when grouped

Before

  1. Select multiple contributions from same contact in find contribution.
  2. selected send thank you letters.
  3. Put the token {contribution.total_amount} into the thank you letter and set grouping to contact (so that it groups multiple transactions into one letter)
  4. Error is shown and no letter is created.

After

PDF rendered, added test passes

Technical Details

The regression was caused by #18714 - however, the fix makes the approach less flakey,. replaceMultipleContributionTokens (only called from one place) was passing in an array where the tokens were already concatenated & expecting the replaceContributionTokens to swap them out as is.

The new approach uses replaceContributionTokens to do the replacing on each contribution (one at a time) and then concatenates the resolved tokens, before using a different function token_replace to do the actual replacements.

Although this code is a bit hardwork it is mostly not called from other places

Comments

https://lab.civicrm.org/dev/core/-/issues/2344

@civibot
Copy link

civibot bot commented Feb 1, 2021

(Standard links)

@civibot civibot bot added the 5.34 label Feb 1, 2021
@eileenmcnaughton eileenmcnaughton changed the title Pdffix dev/core#2344 fix regression affecting sending thank you letters when grouped Feb 1, 2021
@@ -336,7 +339,7 @@ public static function combineContributions($existing, $contribution, $separator
public static function assignCombinedContributionValues($contact, $contributions, $groupBy, $groupByID) {
CRM_Core_Smarty::singleton()->assign('contact_aggregate', $contact['contact_aggregate']);
CRM_Core_Smarty::singleton()
->assign('contributions', array_intersect_key($contributions, $contact['contribution_ids'][$groupBy][$groupByID]));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

contributions is now passed in pre-filtered

$categories = self::getTokenCategories();
$domain = CRM_Core_BAO_Domain::getDomain();
$tokenHtml = CRM_Utils_Token::replaceDomainTokens($html_message, $domain, TRUE, $messageToken);
$tokenHtml = CRM_Utils_Token::replaceContactTokens($tokenHtml, $contact, TRUE, $messageToken);
if ($grouped) {
$tokenHtml = CRM_Utils_Token::replaceMultipleContributionTokens($separator, $tokenHtml, $contribution, TRUE, $messageToken);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The 'TRUE' is eventually ignored so not needed as a param

@eileenmcnaughton eileenmcnaughton changed the title dev/core#2344 fix regression affecting sending thank you letters when grouped dev/core#2344 unit test for fix regression affecting sending thank you letters when grouped Feb 1, 2021
@seamuslee001
Copy link
Contributor

Jenkins re test this please

@eileenmcnaughton
Copy link
Contributor Author

Still the sql gone away fails :-(

@seamuslee001
Copy link
Contributor

Jenkins re test this please

@seamuslee001
Copy link
Contributor

Test fails unrelated

@seamuslee001 seamuslee001 merged commit 5d4ad9d into civicrm:5.34 Feb 1, 2021
@seamuslee001 seamuslee001 deleted the pdffix branch February 1, 2021 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants