Remove function loop on contactIDsSQ
authorEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 23 Jun 2023 00:46:17 +0000 (17:46 -0700)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 23 Jun 2023 00:46:17 +0000 (17:46 -0700)
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
ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/DateAdded.php
ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/RandomSegment.php

index 372a185193515f2749f9fa32314f60f590bc1d68..afedb571623e82b16a569d1505dea667063ed6f0 100644 (file)
@@ -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
    *
index 89d6d5801e427663a30a1c487b8c452c66dec7f3..f6a047296f3e7ad20a34207dc8b061d80a658de2 100644 (file)
@@ -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
index db5110b049181512cb23dcaa18a08ea028601f9e..4e939c0ff3c2d97d77d49907466ae5d647695aaa 100644 (file)
@@ -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