From 47700a1b3cce26735bece2ddcb5f6e8e8015603f Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 5 Dec 2014 07:03:20 -0500 Subject: [PATCH] Fix duplicate contacts on the list after contact delete (#4028) Conflicts: plugins/kolab_addressbook/lib/rcube_kolab_contacts.php --- plugins/kolab_addressbook/lib/rcube_kolab_contacts.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php index fa215834..1443e864 100644 --- a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php +++ b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php @@ -364,7 +364,7 @@ class rcube_kolab_contacts extends rcube_addressbook } } } - else if (isset($this->dataset)) { + else if (!empty($this->dataset)) { // get all records count, skip the query if possible if (!isset($query) || count($this->dataset) < $this->page_size) { $this->result->count = count($this->dataset) + $this->page_size * ($this->list_page - 1); @@ -373,8 +373,11 @@ class rcube_kolab_contacts extends rcube_addressbook $this->result->count = $this->storagefolder->count($query); } - foreach ($this->dataset as $idx => $record) { - $this->result->add($this->_to_rcube_contact($record)); + $start_row = $subset < 0 ? $this->page_size + $subset : 0; + $last_row = min($subset != 0 ? $start_row + abs($subset) : $this->page_size, $this->result->count); + + for ($i = $start_row; $i < $last_row; $i++) { + $this->result->add($this->_to_rcube_contact($this->dataset[$i])); } }