From 0e7133bee4e93e484f66888850fe7c3ce874f65d Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 5 Mar 2019 13:05:16 +1300 Subject: [PATCH] Call getSearchSQLParts to get the desired part instead of sql wrangling --- CRM/Campaign/Selector/Search.php | 6 +++--- CRM/Contact/BAO/GroupContactCache.php | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/CRM/Campaign/Selector/Search.php b/CRM/Campaign/Selector/Search.php index ec046e6ab3..f3315a0b00 100644 --- a/CRM/Campaign/Selector/Search.php +++ b/CRM/Campaign/Selector/Search.php @@ -273,17 +273,17 @@ class CRM_Campaign_Selector_Search extends CRM_Core_Selector_Base implements CRM $cacheKey = "civicrm search {$this->_key}"; Civi::service('prevnext')->deleteItem(NULL, $cacheKey, 'civicrm_contact'); - $sql = $this->_query->getSearchSQL(0, 0, $sort, + $sql = $this->_query->getSearchSQLParts(0, 0, $sort, FALSE, FALSE, FALSE, FALSE, $this->_campaignWhereClause, NULL, $this->_campaignFromClause ); - list($select, $from) = explode(' FROM ', $sql); + $selectSQL = " SELECT %1, contact_a.id, contact_a.display_name -FROM {$from} +FROM {$sql['from']} "; try { diff --git a/CRM/Contact/BAO/GroupContactCache.php b/CRM/Contact/BAO/GroupContactCache.php index e61291cd86..5bad91bed0 100644 --- a/CRM/Contact/BAO/GroupContactCache.php +++ b/CRM/Contact/BAO/GroupContactCache.php @@ -555,15 +555,12 @@ WHERE id IN ( $groupIDs ) ); $query->_useDistinct = FALSE; $query->_useGroupBy = FALSE; - $searchSQL - = $query->searchQuery( + $sqlParts = $query->getSearchSQLParts( 0, 0, NULL, FALSE, FALSE, - FALSE, TRUE, - TRUE, - NULL, NULL, NULL, - TRUE + FALSE, TRUE ); + $searchSQL = "{$sqlParts['select']} {$sqlParts['from']} {$sqlParts['where']} {$sqlParts['having']} {$sqlParts['group_by']}"; } $groupID = CRM_Utils_Type::escape($groupID, 'Integer'); $sql = $searchSQL . " AND contact_a.id NOT IN ( -- 2.25.1