Bug #9349: Fix new subfolder doesn't show in folder list
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 20 Jan 2011 05:00:27 +0000 (22:00 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 20 Jan 2011 05:02:05 +0000 (22:02 -0700)
Problem only occurred if all (unsubscribed) folders are viewed.
hasChildren() was always returning true because we created the parent
element before making the initial hasChildren() check.  Need to check
for children before this.

imp/lib/Imap/Tree.php

index 2efbf4e..fdd7959 100644 (file)
@@ -557,15 +557,15 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator, Serializable
 
         $this->changed = true;
 
+        $prev = ($this->_trackdiff && !is_null($this->_eltdiff) && !isset($this->_eltdiff['a'][$elt['p']]))
+            ? $this->hasChildren($this->_tree[$elt['p']])
+            : null;
+
         /* Set the parent array to the value in $elt['p']. */
         if (empty($this->_parent[$elt['p']])) {
             $this->_parent[$elt['p']] = array();
         }
 
-        $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;