From: eileen Date: Fri, 26 Mar 2021 01:36:39 +0000 (+1300) Subject: Revert attempt to make results re-usable X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f0c2d2580789d88d21331377e3a3877a87cc1288;p=civicrm-core.git 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 --- 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); } /**