Revert attempt to make results re-usable
authoreileen <emcnaughton@wikimedia.org>
Fri, 26 Mar 2021 01:36:39 +0000 (14:36 +1300)
committereileen <emcnaughton@wikimedia.org>
Fri, 26 Mar 2021 01:36:39 +0000 (14:36 +1300)
the DAO throws them away - so we are better just to take the obscure performance hit until we can do
other refactoring

CRM/Contribute/Form/Task/TaskTrait.php

index 7fd195626952c25549c3047db7a148dd0f891a1a..e08185ace1dab00614249ce9d6d104172a123a7d 100644 (file)
@@ -35,34 +35,31 @@ trait CRM_Contribute_Form_Task_TaskTrait {
    * @throws \CRM_Core_Exception
    */
   public function getSearchQueryResults(): CRM_Core_DAO {
-    if (!$this->queryBAO) {
-      $form = $this;
-      $queryParams = $this->getQueryParams();
-      $returnProperties = ['contribution_id' => 1];
-      $sortOrder = $sortCol = NULL;
-      if ($form->get(CRM_Utils_Sort::SORT_ORDER)) {
-        $sortOrder = $form->get(CRM_Utils_Sort::SORT_ORDER);
-        //Include sort column in select clause.
-        $sortCol = trim(str_replace(['`', 'asc', 'desc'], '', $sortOrder));
-        $returnProperties[$sortCol] = 1;
-      }
+    $form = $this;
+    $queryParams = $this->getQueryParams();
+    $returnProperties = ['contribution_id' => 1];
+    $sortOrder = $sortCol = NULL;
+    if ($form->get(CRM_Utils_Sort::SORT_ORDER)) {
+      $sortOrder = $form->get(CRM_Utils_Sort::SORT_ORDER);
+      //Include sort column in select clause.
+      $sortCol = trim(str_replace(['`', 'asc', 'desc'], '', $sortOrder));
+      $returnProperties[$sortCol] = 1;
+    }
 
-      $query = new CRM_Contact_BAO_Query($queryParams, $returnProperties, NULL, FALSE, FALSE,
-        CRM_Contact_BAO_Query::MODE_CONTRIBUTE
-      );
-      // @todo the function CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled should handle this
-      // can we remove? if not why not?
-      if ($this->isQueryIncludesSoftCredits()) {
-        $query->_rowCountClause = ' count(civicrm_contribution.id)';
-        $query->_groupByComponentClause = ' GROUP BY contribution_search_scredit_combined.id, contribution_search_scredit_combined.contact_id, contribution_search_scredit_combined.scredit_id ';
-      }
-      else {
-        $query->_distinctComponentClause = ' civicrm_contribution.id';
-        $query->_groupByComponentClause = ' GROUP BY civicrm_contribution.id ';
-      }
-      $this->queryBAO = $query->searchQuery(0, 0, $sortOrder);
+    $query = new CRM_Contact_BAO_Query($queryParams, $returnProperties, NULL, FALSE, FALSE,
+      CRM_Contact_BAO_Query::MODE_CONTRIBUTE
+    );
+    // @todo the function CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled should handle this
+    // can we remove? if not why not?
+    if ($this->isQueryIncludesSoftCredits()) {
+      $query->_rowCountClause = ' count(civicrm_contribution.id)';
+      $query->_groupByComponentClause = ' GROUP BY contribution_search_scredit_combined.id, contribution_search_scredit_combined.contact_id, contribution_search_scredit_combined.scredit_id ';
+    }
+    else {
+      $query->_distinctComponentClause = ' civicrm_contribution.id';
+      $query->_groupByComponentClause = ' GROUP BY civicrm_contribution.id ';
     }
-    return $this->queryBAO;
+    return $query->searchQuery(0, 0, $sortOrder);
   }
 
   /**