From f0c2d2580789d88d21331377e3a3877a87cc1288 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 26 Mar 2021 14:36:39 +1300 Subject: [PATCH] Revert attempt to make results re-usable 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 | 49 ++++++++++++-------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/CRM/Contribute/Form/Task/TaskTrait.php b/CRM/Contribute/Form/Task/TaskTrait.php index 7fd1956269..e08185ace1 100644 --- a/CRM/Contribute/Form/Task/TaskTrait.php +++ b/CRM/Contribute/Form/Task/TaskTrait.php @@ -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); } /** -- 2.25.1