Move handling for soft credits to the only form that uses it
authoreileen <emcnaughton@wikimedia.org>
Thu, 25 Mar 2021 07:18:56 +0000 (20:18 +1300)
committereileen <emcnaughton@wikimedia.org>
Fri, 26 Mar 2021 01:35:52 +0000 (14:35 +1300)
CRM/Contribute/Form/Task.php
CRM/Contribute/Form/Task/PDFLetterCommon.php

index f73b7c0934c7af837490018a3be7c182e8d9f847..53df76a8b5073d0bfaa8c9d761dab231a85df530 100644 (file)
@@ -30,13 +30,6 @@ class CRM_Contribute_Form_Task extends CRM_Core_Form_Task {
    */
   protected $_contributionIds;
 
-  /**
-   * The array that holds all the mapping contribution and contact ids.
-   *
-   * @var array
-   */
-  protected $_contributionContactIds = [];
-
   /**
    * Build all the data structures needed to build the form.
    */
@@ -61,10 +54,6 @@ class CRM_Contribute_Form_Task extends CRM_Core_Form_Task {
       $result = $form->getSearchQueryResults();
       while ($result->fetch()) {
         $ids[] = $result->contribution_id;
-        if ($form->isQueryIncludesSoftCredits()) {
-          $form->_contactIds[$result->contact_id] = $result->contact_id;
-          $form->_contributionContactIds["{$result->contact_id}-{$result->contribution_id}"] = $result->contribution_id;
-        }
       }
       $form->assign('totalSelectedContributions', $form->get('rowCount'));
     }
index af0b20f90c249dd37cf14f20f5c523813cdf8d39..e776799adac907f2f5e990bb3cd27051fed0557f 100644 (file)
@@ -25,6 +25,8 @@ class CRM_Contribute_Form_Task_PDFLetterCommon extends CRM_Contact_Form_Task_PDF
    *
    * @param \CRM_Contribute_Form_Task_PDFLetter $form
    * @param array $formValues
+   *
+   * @throws \CRM_Core_Exception
    */
   public static function postProcess(&$form, $formValues = NULL) {
     if (empty($formValues)) {
@@ -79,8 +81,12 @@ class CRM_Contribute_Form_Task_PDFLetterCommon extends CRM_Contact_Form_Task_PDF
     $skipDeceased = $form->skipDeceased ?? TRUE;
     $contributionIDs = $form->getVar('_contributionIds');
     if ($form->isQueryIncludesSoftCredits()) {
-      //@todo - comment on what is stored there
-      $contributionIDs = $form->getVar('_contributionContactIds');
+      $contributionIDs = [];
+      $result = $form->getSearchQueryResults();
+      while ($result->fetch()) {
+        $form->_contactIds[$result->contact_id] = $result->contact_id;
+        $contributionIDs["{$result->contact_id}-{$result->contribution_id}"] = $result->contribution_id;
+      }
     }
     [$contributions, $contacts] = self::buildContributionArray($groupBy, $contributionIDs, $returnProperties, $skipOnHold, $skipDeceased, $messageToken, $task, $separator, $form->isQueryIncludesSoftCredits());
     $html = [];