From 53b5ccfb0cf22dcd57c039c8238431f7edb77b8b Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 5 Aug 2016 09:47:27 -0400 Subject: [PATCH] Fix regression where LDAP results could be counted incorrectly when using VLV ... broken by d08bd0a51f9 where we added searching in users+groups in one request --- program/lib/Roundcube/rcube_ldap.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/program/lib/Roundcube/rcube_ldap.php b/program/lib/Roundcube/rcube_ldap.php index 999bfee89..857b10daf 100644 --- a/program/lib/Roundcube/rcube_ldap.php +++ b/program/lib/Roundcube/rcube_ldap.php @@ -586,7 +586,8 @@ class rcube_ldap extends rcube_addressbook // filter entries for this page for ($i = $start_row; $i < min($entries['count'], $last_row); $i++) - $this->result->add($this->_ldap2result($entries[$i])); + if ($entries[$i]) + $this->result->add($this->_ldap2result($entries[$i])); return $this->result; } @@ -933,7 +934,8 @@ class rcube_ldap extends rcube_addressbook // we have a search result resource, get all entries if (!$count && $result) { - $result = $result->entries(); + $result_count = $result->count(); + $result = $result->entries(); unset($result['count']); } @@ -958,10 +960,11 @@ class rcube_ldap extends rcube_addressbook if ($count && $res) { $result += $res; } - else if (!$count && $res && $res->count()) { + else if (!$count && $res && ($res_count = $res->count())) { $res = $res->entries(); unset($res['count']); $result = array_merge($result, $res); + $result_count += $res_count; } } @@ -971,7 +974,7 @@ class rcube_ldap extends rcube_addressbook usort($result, array($this, '_entry_sort_cmp')); } - $result['count'] = count($result); + $result['count'] = $result_count; $this->result_entries = $result; }