From a7d6a3b62dba007a354dd770d523a63e112ba167 Mon Sep 17 00:00:00 2001 From: eileen Date: Sun, 3 Nov 2019 17:41:34 +1300 Subject: [PATCH] Move CustomQuery iteraction out of the tail end of the SelectClause It's not part of the select clause so having it in there is confusing & mislead. No functional change as it's the next thin to be called either way --- CRM/Contact/BAO/Query.php | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 685ae04a47..d072e74491 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -579,6 +579,17 @@ class CRM_Contact_BAO_Query { $this->_whereTables = $this->_tables; $this->selectClause($apiEntity); + if (!empty($this->_cfIDs)) { + // @todo This function is the select function but instead of running 'select' it + // is running the whole query. + $this->_customQuery = new CRM_Core_BAO_CustomQuery($this->_cfIDs, TRUE, $this->_locationSpecificCustomFields); + $this->_customQuery->query(); + $this->_select = array_merge($this->_select, $this->_customQuery->_select); + $this->_element = array_merge($this->_element, $this->_customQuery->_element); + $this->_tables = array_merge($this->_tables, $this->_customQuery->_tables); + $this->_whereTables = array_merge($this->_whereTables, $this->_customQuery->_whereTables); + $this->_options = $this->_customQuery->_options; + } $isForcePrimaryOnly = !empty($apiEntity); $this->_whereClause = $this->whereClause($isForcePrimaryOnly); if (array_key_exists('civicrm_contribution', $this->_whereTables)) { @@ -1029,18 +1040,6 @@ class CRM_Contact_BAO_Query { CRM_Core_Component::alterQuery($this, 'select'); CRM_Contact_BAO_Query_Hook::singleton()->alterSearchQuery($this, 'select'); - - if (!empty($this->_cfIDs)) { - // @todo This function is the select function but instead of running 'select' it - // is running the whole query. - $this->_customQuery = new CRM_Core_BAO_CustomQuery($this->_cfIDs, TRUE, $this->_locationSpecificCustomFields); - $this->_customQuery->query(); - $this->_select = array_merge($this->_select, $this->_customQuery->_select); - $this->_element = array_merge($this->_element, $this->_customQuery->_element); - $this->_tables = array_merge($this->_tables, $this->_customQuery->_tables); - $this->_whereTables = array_merge($this->_whereTables, $this->_customQuery->_whereTables); - $this->_options = $this->_customQuery->_options; - } } /** -- 2.25.1