From: Michael M Slusarz Date: Tue, 7 Sep 2010 05:04:40 +0000 (-0600) Subject: Fix Bug #9041 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=be741280870c216ca0d21e9a262e045b4899c1c5;p=horde.git Fix Bug #9041 Correctly determine folder diff when folder contains unsubscribed mailboxes, which are not visible in the current mode. --- diff --git a/imp/lib/Imap/Tree.php b/imp/lib/Imap/Tree.php index f8bdcfad2..9e9fb7af0 100644 --- a/imp/lib/Imap/Tree.php +++ b/imp/lib/Imap/Tree.php @@ -557,20 +557,20 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator, Serializable /* Set the parent array to the value in $elt['p']. */ if (empty($this->_parent[$elt['p']])) { $this->_parent[$elt['p']] = array(); - // This is a case where it is possible that the parent element has - // changed (it now has children) but we can't catch it via the - // bitflag (since hasChildren() is dynamically determined). - if ($this->_trackdiff && - !is_null($this->_eltdiff) && - !isset($this->_eltdiff['a'][$elt['p']])) { - $this->_eltdiff['c'][$elt['p']] = 1; - } } + + $prev = ($this->_trackdiff && !is_null($this->_eltdiff) && !isset($this->_eltdiff['a'][$elt['p']])) + ? $this->hasChildren($this->_tree[$elt['p']]) + : null; + $this->_parent[$elt['p']][] = $elt['v']; $this->_tree[$elt['v']] = $elt; - if ($this->_trackdiff && !is_null($this->_eltdiff)) { + if (!is_null($prev)) { $this->_eltdiff['a'][$elt['v']] = 1; + if ($this->hasChildren($this->_tree[$elt['p']]) != $prev) { + $this->_eltdiff['c'][$elt['p']] = 1; + } } /* Make sure we are sorted correctly. */ @@ -696,6 +696,11 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator, Serializable } else { /* Rebuild the parent tree. */ $this->_parent[$parent] = array_values($this->_parent[$parent]); + + if (!is_null($this->_eltdiff) && + !$this->hasChildren($this->_tree[$parent])) { + $this->_eltdiff['c'][$parent] = 1; + } } /* Remove the mailbox from the expanded folders list. */