From 8cfb2c997fd78fc4bd7c29de1d07f9d8717962ae Mon Sep 17 00:00:00 2001 From: nathangray Date: Thu, 23 Mar 2017 11:34:35 -0600 Subject: [PATCH] Silence error_log, hopefully fix wrong row count --- api/src/Contacts/Sql.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/api/src/Contacts/Sql.php b/api/src/Contacts/Sql.php index 92c1aad423..398aea457d 100644 --- a/api/src/Contacts/Sql.php +++ b/api/src/Contacts/Sql.php @@ -375,8 +375,6 @@ 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) { @@ -384,19 +382,11 @@ class Sql extends Api\Storage } $rows = $this->db->query( - "SELECT " . $columns. ', COUNT(contact_id) AS group_count' . + "SELECT $mysql_calc_rows " . $columns. ', COUNT(contact_id) AS group_count' . ' FROM (' . $sub_query . ') AS matches GROUP BY ' . implode(',',$group) . ' HAVING group_count > 1 ORDER BY ' . $order, __LINE__, __FILE__, (int)$param['start'],$mysql_calc_rows ? (int)$param['num_rows'] : -1 ); - if ($mysql_calc_rows) - { - $this->total = $this->db->query('SELECT FOUND_ROWS()')->fetchColumn(); - } - else - { - $this->total = $rows->NumRows(); - } // Go through rows and only return one for each pair/triplet/etc. of matches $dupes = array(); @@ -406,6 +396,15 @@ class Sql extends Api\Storage $row['email_home'] = $row['contact_email_home']; $dupes[] = $this->db2data($row); } + + if ($mysql_calc_rows) + { + $this->total = $this->db->query('SELECT FOUND_ROWS()')->fetchColumn(); + } + else + { + $this->total = $rows->NumRows(); + } return $dupes; }