From d5386625d5a98db26be3069565a0da9c8835fa04 Mon Sep 17 00:00:00 2001 From: nathangray Date: Fri, 17 Mar 2017 10:01:23 -0600 Subject: [PATCH] Addressbook - Duplicate view - Fix a bug with types, add some debug to help with long queries. --- addressbook/inc/class.addressbook_hooks.inc.php | 2 +- api/src/Contacts/Sql.php | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/addressbook/inc/class.addressbook_hooks.inc.php b/addressbook/inc/class.addressbook_hooks.inc.php index a8a5296c85..786b331342 100644 --- a/addressbook/inc/class.addressbook_hooks.inc.php +++ b/addressbook/inc/class.addressbook_hooks.inc.php @@ -209,7 +209,7 @@ class addressbook_hooks 'values' => $duplicate_options, 'help' => 'Fields to consider when looking for duplicate contacts.', 'admin' => false, - 'default' => 'n_family, n_given, org_name, contact_email' + 'default' => 'n_family, org_name, contact_email' ); $settings['duplicate_threshold'] = array( 'type' => 'input', diff --git a/api/src/Contacts/Sql.php b/api/src/Contacts/Sql.php index acf00096b8..3871a78f43 100644 --- a/api/src/Contacts/Sql.php +++ b/api/src/Contacts/Sql.php @@ -285,10 +285,11 @@ class Sql extends Api\Storage $join .= str_replace('cat_id', 'a2.cat_id', $cat_filter) . ' AND '; unset($filter['cat_id']); } - if ($param['col_filter']['tid']) + if ($filter['tid']) { - $filter['contact_tid'] = $param['col_filter']['tid']; - $join .= 'a2.contact_tid = ' . $this->db->quote($filter['contact_tid']) . ' AND '; + $filter[$this->table_name . '.contact_tid'] = $param['col_filter']['tid']; + $join .= 'a2.contact_tid = ' . $this->db->quote($filter['tid']) . ' AND '; + unset($filter['tid']); } else { @@ -331,7 +332,7 @@ class Sql extends Api\Storage $sort = $param['sort'] == 'DESC' ? 'DESC' : 'ASC'; $group = $GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_fields'] ? explode(',',$GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_fields']): - array('n_family', 'n_given', 'org_name', 'contact_email'); + array('n_family', 'org_name', 'contact_email'); $match_count = $GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_threshold'] ? $GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_threshold'] : 3; @@ -374,6 +375,8 @@ class Sql extends Api\Storage $join ); + error_log(__METHOD__ . ':'.__LINE__ . ' Subquery: ' . $sub_query); + $columns = implode(', ', $group); if ($this->db->Type == 'mysql' && $this->db->ServerInfo['version'] >= 4.0) {