From ac9ceec70e7b881ca94b4adba211632e7c1180a6 Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 27 Jul 2019 12:20:26 +1200 Subject: [PATCH] [Code-quality] remove references to where_tables, where_clause I've long been of the impression that the where_tables & where_clause in the Smart group & group tables are not actually used. On going through I found places where they are saved to but not any where they are used. This removes them - next step would be to actually drop the fields but need Jenkins & another person to agree with me first --- CRM/Contact/BAO/Group.php | 20 ------------------ CRM/Contact/BAO/SavedSearch.php | 37 --------------------------------- sql/GenerateData.php | 2 -- sql/GenerateReportData.php | 2 -- 4 files changed, 61 deletions(-) diff --git a/CRM/Contact/BAO/Group.php b/CRM/Contact/BAO/Group.php index 552db8f9d1..074fcf2623 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -421,7 +421,6 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { $group->name = substr($group->name, 0, -4) . "_{$group->id}"; } - $group->buildClause(); $group->save(); // add custom field values @@ -501,25 +500,6 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { return $group; } - /** - * Given a saved search compute the clause and the tables - * and store it for future use - */ - public function buildClause() { - $params = [['group', 'IN', [$this->id], 0, 0]]; - - if (!empty($params)) { - $tables = $whereTables = []; - $this->where_clause = CRM_Contact_BAO_Query::getWhereClause($params, NULL, $tables, $whereTables); - if (!empty($tables)) { - $this->select_tables = serialize($tables); - } - if (!empty($whereTables)) { - $this->where_tables = serialize($whereTables); - } - } - } - /** * Defines a new smart group. * diff --git a/CRM/Contact/BAO/SavedSearch.php b/CRM/Contact/BAO/SavedSearch.php index b3561a72fe..2c73e9df08 100644 --- a/CRM/Contact/BAO/SavedSearch.php +++ b/CRM/Contact/BAO/SavedSearch.php @@ -324,43 +324,6 @@ LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_ } } - /** - * Given a saved search compute the clause and the tables and store it for future use. - */ - public function buildClause() { - $fv = unserialize($this->form_values); - - if ($this->mapping_id) { - $params = CRM_Core_BAO_Mapping::formattedFields($fv); - } - else { - $params = CRM_Contact_BAO_Query::convertFormValues($fv); - } - - if (!empty($params)) { - $tables = $whereTables = []; - $this->where_clause = CRM_Contact_BAO_Query::getWhereClause($params, NULL, $tables, $whereTables); - if (!empty($tables)) { - $this->select_tables = serialize($tables); - } - if (!empty($whereTables)) { - $this->where_tables = serialize($whereTables); - } - } - } - - /** - * Save the search. - * - * @param bool $hook - */ - public function save($hook = TRUE) { - // first build the computed fields - $this->buildClause(); - - parent::save($hook); - } - /** * Given an id, get the name of the saved search. * diff --git a/sql/GenerateData.php b/sql/GenerateData.php index ebd098bdd4..f3b7274bc1 100644 --- a/sql/GenerateData.php +++ b/sql/GenerateData.php @@ -1119,8 +1119,6 @@ class CRM_GCD { $group->visibility = 'Public Pages'; $group->is_active = 1; $group->save(); - $group->buildClause(); - $group->save(); } // 60 are for newsletter diff --git a/sql/GenerateReportData.php b/sql/GenerateReportData.php index e3b1dfd332..0eeacf25e0 100644 --- a/sql/GenerateReportData.php +++ b/sql/GenerateReportData.php @@ -1087,8 +1087,6 @@ class CRM_GCD { $group->visibility = 'Public Pages'; $group->is_active = 1; $group->save(); - $group->buildClause(); - $group->save(); } // 60 are for newsletter -- 2.25.1