6.0.0-beta1
7/9/25

[#4987] IMP_Tree::insert() burfs when it sees a parent with nothing in it
Summary IMP_Tree::insert() burfs when it sees a parent with nothing in it
Queue IMP
Queue Version HEAD
Type Bug
State Resolved
Priority 2. Medium
Owners
Requester ntai (at) smartfruit (dot) com
Created 02/08/2007 (6726 days ago)
Due
Updated 02/10/2007 (6724 days ago)
Assigned 02/09/2007 (6725 days ago)
Resolved 02/10/2007 (6724 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
02/10/2007 10:49:52 PM Michael Slusarz Comment #4
State ⇒ Resolved
Reply to this comment
Added a sanity check to skip adding an element if getList() returns empty.
02/10/2007 10:41:36 PM Michael Slusarz Deleted Original Message
 
02/09/2007 06:01:59 PM ntai (at) smartfruit (dot) com Comment #3
New Attachment: foo.txt
Reply to this comment
print_f($newboxes) is in attachement


02/09/2007 10:45:03 AM Jan Schneider State ⇒ Feedback
 
02/09/2007 06:09:36 AM Michael Slusarz Comment #2 Reply to this comment
It burfed on me when IMP_Tree was retriveing a tree from IMAP account
which consists of a folder with nothing?.

Here is what I had to do to make this work.

$ob = $this->_getList($id); somehow managed to return null. This may
or may not be the problem of IMAP driver, which I do not know.
What is imap_getmailboxes() returning in _getList()?  i.e. what does a 
print_r($newboxes) right after that call return?
02/08/2007 11:07:25 PM ntai (at) smartfruit (dot) com Comment #1
Priority ⇒ 2. Medium
Type ⇒ Bug
Summary ⇒ IMP_Tree::insert() burfs when it sees a parent with nothing in it
Queue ⇒ IMP
State ⇒ Unconfirmed
Reply to this comment
It burfed on me when IMP_Tree was retriveing a tree from IMAP account 
which consists of a folder with nothing?.



Here is what I had to do to make this work.



$ob = $this->_getList($id); somehow managed to return null. This may 
or may not be the problem of IMAP driver, which I do not know.



Since $ob is nothing, I changed the function to not burf seeing null $ob.

I don't have enough klowledge to do the real fix but the change works for me.







Index: Tree.php

===================================================================

RCS file: /repository/imp/lib/IMAP/Tree.php,v

retrieving revision 1.144

diff -c -r1.144 Tree.php

*** Tree.php        4 Feb 2007 05:13:11 -0000        1.144

--- Tree.php        8 Feb 2007 23:02:42 -0000

***************

*** 337,343 ****

                       /* Strip off server string. */

                       $box = $this->_removeServerString($box);

                       if ($box->name && !isset($unique[$box->name])) {

!                         $unique[$box->name] = $box;

                       }

                   }

               }

--- 337,345 ----

                       /* Strip off server string. */

                       $box = $this->_removeServerString($box);

                       if ($box->name && !isset($unique[$box->name])) {

!                         if ( ($box->name . '/%') != $path) {

!                             $unique[$box->name] = $box;

!                         }

                       }

                   }

               }

***************

*** 830,845 ****

                   }

               } else {

                   $ob = $this->_getList($id);

!                 $elt = $this->_makeMailboxTreeElt(reset($ob));

!                 if (!$this->isSubscribed($elt)) {

!                     $tmp = @imap_lsub($imp_imap->stream(), 
$this->_server, $elt['v']);

!                     if (!empty($tmp)) {

!                         $this->_setSubscribed($elt, true);

                       }

                   }

               }



!             if ($this->_insertElt($elt)) {

                   /* We know that the parent folder has children. */

                   if (isset($this->_tree[$elt['p']])) {

                       $this->_setChildren($this->_tree[$elt['p']], true);

--- 832,852 ----

                   }

               } else {

                   $ob = $this->_getList($id);

!                 if ($ob) {

!                     $elt = $this->_makeMailboxTreeElt(reset($ob));

!                     if (!$this->isSubscribed($elt)) {

!                         $tmp = @imap_lsub($imp_imap->stream(), 
$this->_server, $elt['v']);

!                         if (!empty($tmp)) {

!                             $this->_setSubscribed($elt, true);

!                         }

                       }

                   }

+                 else {

+                     $elt = null;

+                 }

               }



!             if ($elt && $this->_insertElt($elt)) {

                   /* We know that the parent folder has children. */

                   if (isset($this->_tree[$elt['p']])) {

                       $this->_setChildren($this->_tree[$elt['p']], true);


Saved Queries