From: monishdeb Date: Tue, 27 May 2014 12:09:43 +0000 (+0530) Subject: Minor fixes in fulltext search X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=1e12e492363cb21213cd2263c33ede4130c91381;p=civicrm-core.git Minor fixes in fulltext search --- diff --git a/CRM/Contact/Form/Search/Custom/FullText.php b/CRM/Contact/Form/Search/Custom/FullText.php index aaefb737cd..1801ceb71a 100644 --- a/CRM/Contact/Form/Search/Custom/FullText.php +++ b/CRM/Contact/Form/Search/Custom/FullText.php @@ -148,6 +148,7 @@ class CRM_Contact_Form_Search_Custom_FullText implements CRM_Contact_Form_Search 'table_name' => 'varchar(16)', 'contact_id' => 'int unsigned', 'sort_name' => 'varchar(128)', + 'display_name' => 'varchar(128)', 'assignee_contact_id' => 'int unsigned', 'assignee_sort_name' => 'varchar(128)', 'target_contact_id' => 'int unsigned', @@ -871,12 +872,11 @@ WHERE (c.sort_name LIKE {$this->_text} OR c.display_name LIKE {$this->_text function contactIDs($offset = 0, $rowcount = 0, $sort = NULL, $returnSQL = FALSE) { $this->initialize(); - $sql = "SELECT contact_id FROM {$this->_tableName}"; if ($returnSQL) { - return $sql; + return $this->all($offset, $rowcount, $sort, FALSE, TRUE);; } else { - return CRM_Core_DAO::singleValueQuery($sql); + return CRM_Core_DAO::singleValueQuery("SELECT contact_id FROM {$this->_tableName}"); } } @@ -893,7 +893,7 @@ WHERE (c.sort_name LIKE {$this->_text} OR c.display_name LIKE {$this->_text $this->initialize(); if ($justIDs) { - $select = "contact_a.contact_id"; + $select = "contact_a.id as contact_id"; } else { $select = " @@ -965,8 +965,8 @@ FROM {$this->_tableName} contact_a case 'Contact': $sql = " INSERT INTO {$this->_tableName} -( contact_id, sort_name, table_name ) -SELECT c.id, c.sort_name, 'Contact' +( contact_id, sort_name, display_name, table_name ) +SELECT c.id, c.sort_name, c.display_name, 'Contact' FROM {$this->_entityIDTableName} ct INNER JOIN civicrm_contact c ON ct.entity_id = c.id {$this->_limitDetailClause} diff --git a/CRM/Contact/Selector.php b/CRM/Contact/Selector.php index 49042178a5..197b2180ce 100644 --- a/CRM/Contact/Selector.php +++ b/CRM/Contact/Selector.php @@ -977,7 +977,6 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se if (is_a($this, 'CRM_Contact_Selector_Custom')) { $sql = $this->_search->contactIDs($start, $end, $sort, TRUE); $replaceSQL = "SELECT contact_a.id as contact_id"; - $coreSearch = FALSE; } // For core searches use the searchQuery method @@ -995,13 +994,14 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se // the prev next cache in this situation // the other alternative of running the FULL query will just be incredibly inefficient // and slow things down way too much on large data sets / complex queries + $insertSQL = " INSERT INTO civicrm_prevnext_cache ( entity_table, entity_id1, entity_id2, cacheKey, data ) SELECT 'civicrm_contact', contact_a.id, contact_a.id, '$cacheKey', contact_a.display_name "; - $sql = str_replace($replaceSQL, $insertSQL, $sql); + CRM_Core_Error::debug_var( '$sql', $sql ); $errorScope = CRM_Core_TemporaryErrorScope::ignoreException(); $result = CRM_Core_DAO::executeQuery($sql);