From 3cffe8fc39737ad64d76ae6c4f37e5b24cf9e1f4 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 22 Jun 2023 17:46:17 -0700 Subject: [PATCH] Remove function loop on contactIDsSQ The only functions that call contactIDsSQl are 2 custom searches from my searching. One is disabled I tested the Date Add search with calling the secondary function directly & it worked so the contactIDsSql can go... --- CRM/Contact/BAO/SavedSearch.php | 26 ------------------- .../Contact/Form/Search/Custom/DateAdded.php | 4 +-- .../Form/Search/Custom/RandomSegment.php | 4 +-- 3 files changed, 4 insertions(+), 30 deletions(-) diff --git a/CRM/Contact/BAO/SavedSearch.php b/CRM/Contact/BAO/SavedSearch.php index 372a185193..afedb57162 100644 --- a/CRM/Contact/BAO/SavedSearch.php +++ b/CRM/Contact/BAO/SavedSearch.php @@ -223,32 +223,6 @@ class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch implements return NULL; } - /** - * Contact IDS Sql (whatever that means!). - * - * @param int $id - * - * @return string - */ - public static function contactIDsSQL($id) { - $params = self::getSearchParams($id); - if ($params && !empty($params['customSearchID'])) { - return CRM_Contact_BAO_SearchCustom::contactIDSQL(NULL, $id); - } - else { - $tables = $whereTables = ['civicrm_contact' => 1]; - $where = CRM_Contact_BAO_SavedSearch::whereClause($id, $tables, $whereTables); - if (!$where) { - $where = '( 1 )'; - } - $from = CRM_Contact_BAO_Query::fromClause($whereTables); - return " -SELECT contact_a.id -$from -WHERE $where"; - } - } - /** * Deprecated function, gets a value from Group entity * diff --git a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/DateAdded.php b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/DateAdded.php index 89d6d5801e..f6a047296f 100644 --- a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/DateAdded.php +++ b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/DateAdded.php @@ -247,7 +247,7 @@ class CRM_Contact_Form_Search_Custom_DateAdded extends CRM_Contact_Form_Search_C if (in_array($values, $smartGroup)) { $ssId = CRM_Utils_Array::key($values, $smartGroup); - $smartSql = CRM_Contact_BAO_SavedSearch::contactIDsSQL($ssId); + $smartSql = CRM_Contact_BAO_SearchCustom::contactIDSQL(NULL, $ssId); $smartSql = $smartSql . " AND contact_a.id NOT IN ( SELECT contact_id FROM civicrm_group_contact @@ -295,7 +295,7 @@ class CRM_Contact_Form_Search_Custom_DateAdded extends CRM_Contact_Form_Search_C $ssId = CRM_Utils_Array::key($values, $smartGroup); - $smartSql = CRM_Contact_BAO_SavedSearch::contactIDsSQL($ssId); + $smartSql = CRM_Contact_BAO_SearchCustom::contactIDSQL(NULL, $ssId); $smartSql .= " AND contact_a.id IN ( SELECT id AS contact_id diff --git a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/RandomSegment.php b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/RandomSegment.php index db5110b049..4e939c0ff3 100644 --- a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/RandomSegment.php +++ b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/RandomSegment.php @@ -194,7 +194,7 @@ class CRM_Contact_Form_Search_Custom_RandomSegment extends CRM_Contact_Form_Sear if (in_array($values, $smartGroup)) { $ssId = CRM_Utils_Array::key($values, $smartGroup); - $smartSql = CRM_Contact_BAO_SavedSearch::contactIDsSQL($ssId); + $smartSql = CRM_Contact_BAO_SearchCustom::contactIDSQL(NULL, $ssId); $smartSql = $smartSql . " AND contact_a.id NOT IN ( SELECT contact_id FROM civicrm_group_contact @@ -245,7 +245,7 @@ class CRM_Contact_Form_Search_Custom_RandomSegment extends CRM_Contact_Form_Sear $ssId = CRM_Utils_Array::key($values, $smartGroup); - $smartSql = CRM_Contact_BAO_SavedSearch::contactIDsSQL($ssId); + $smartSql = CRM_Contact_BAO_SearchCustom::contactIDSQL(NULL, $ssId); $smartSql .= " AND contact_a.id NOT IN ( SELECT contact_id FROM civicrm_group_contact -- 2.25.1