[imp] Re: Extremely weird IMAP behaviour - IMP or c-client problem?

Eli eli-list at experthost.com
Wed Mar 23 17:55:12 PST 2005


I wrote:
> Whenever I get a login failure and IMP kicks me back to a 
> login screen, there is *NOTHING* happening by way of internet 
> traffic!

This was my own fault - an error in logic in my preauth hook.  This problem
has been solved.

> I have confirmed that it seems IMP doesn't know how to
> list folders for the SmartMax IMAP daemon

I retract that statement and substitute the truth...

I have done function call tracing within Horde and IMP and have *finally*
found the exact point where the infinite loop occurs.  My problem now is, I
still cannot tell for sure if it's a problem with the IMAP result from the
IMAP daemon, or a PHP code problem in Horde, or a bug in c-client.

Here is what I have so far...

In /horde/lib/Horde/IMAP/Tree.php in the _addLevel() function, the foreach
command is looping forever on the "INBOX".  Each time this is run, (I think)
it runs an IMAP command to do something like this:

0 LIST "" INBOX/%
* LIST (\NoInferiors) NIL INBOX
0 OK LIST completed.

That includes the result from the IMAP server BTW :)  Now, as Joseph
mentioned earlier on, it might appear that the IMAP daemon is showing that
the INBOX appears to have a subfolder called INBOX?  If it is, that could
explain why this loop happens - but should it?

I put trigger_error() lines throughout code and turned up with this (the
number sections are traces through functions for my reference).  Please note
that due to me adding debugging code, the line numbers are off, so you may
use this as a reference to see what happens where:

------------------------------------------------------------------------
    function _addLevel($list)
    {
trigger_error("9.1.8.5.3.6.1");
        $expandall = ($this->_initmode & IMAPTREE_INIT_FETCHALL);
        $isparent = false;

trigger_error("9.1.8.5.3.6.2");
        foreach ($list as $val) {
trigger_error("9.1.8.5.3.6.3 - loop");
ob_start();
print_r($val);
trigger_error("              val = \n" . ob_get_contents() . "\n");
ob_end_flush();
            $elt = $this->_makeMailboxTreeElt($val);
            $isparent = true;
            $parent = $elt['p'];
            $this->_insertElt($elt);

trigger_error("9.1.8.5.3.6.4");
            if ($expandall || $this->isOpen($elt)) {
trigger_error("9.1.8.5.3.6.5");
ob_start();
print_r($elt);
trigger_error("              elt = \n" . ob_get_contents() . "\n");
ob_end_flush();
                $this->expand($elt['v']);
trigger_error("9.1.8.5.3.6.6");
            } else {
trigger_error("9.1.8.5.3.6.7");
                $this->_childrenInfo($elt['v'], false, true);
            }
trigger_error("9.1.8.5.3.6.8 - loop end");
        }

trigger_error("9.1.8.5.3.6.9");
        /* Sort the list. */
        if ($isparent &&
            !empty($this->_parent[$parent]) &&
            (count($this->_parent[$parent]) > 1)) {
trigger_error("9.1.8.5.3.6.10");
            $this->_setNeedSort($this->_tree[$parent], true);
        }
trigger_error("9.1.8.5.3.6.11");
    }
------------------------------------------------------------------------

... and here is the debug output:

------------------------------------------------------------------------
[Wed Mar 23 20:33:02 2005] [error] PHP Notice:  9.1.8.5.3.6.2 in
/home/www/test/horde/lib/Horde/IMAP/Tree.php on line 1092
[Wed Mar 23 20:33:02 2005] [error] PHP Notice:  9.1.8.5.3.6.3 - loop in
/home/www/test/horde/lib/Horde/IMAP/Tree.php on line 1094
[Wed Mar 23 20:33:02 2005] [error] PHP Notice:                val =
stdClass Object
(
    [name] => INBOX
    [attributes] => 1
    [delimiter] =>
    [fullServerPath] => {66.165.106.126:143/imap/notls}INBOX
)

 in /home/www/test/horde/lib/Horde/IMAP/Tree.php on line 1097
[Wed Mar 23 20:33:02 2005] [error] PHP Notice:  9.1.8.5.3.6.4 in
/home/www/test/horde/lib/Horde/IMAP/Tree.php on line 1104
[Wed Mar 23 20:33:02 2005] [error] PHP Notice:  9.1.8.5.3.6.5 in
/home/www/test/horde/lib/Horde/IMAP/Tree.php on line 1106
[Wed Mar 23 20:33:02 2005] [error] PHP Notice:                elt =
Array
(
    [a] => 2561
    [p] =>
    [v] => INBOX
    [c] => 0
    [l] => INBOX
)

 in /home/www/test/horde/lib/Horde/IMAP/Tree.php on line 1109
[Wed Mar 23 20:33:02 2005] [error] PHP Notice:  9.1.8.5.3.6.1 in
/home/www/test/horde/lib/Horde/IMAP/Tree.php on line 1088
[Wed Mar 23 20:33:02 2005] [error] PHP Notice:  9.1.8.5.3.6.2 in
/home/www/test/horde/lib/Horde/IMAP/Tree.php on line 1092
[Wed Mar 23 20:33:02 2005] [error] PHP Notice:  9.1.8.5.3.6.3 - loop in
/home/www/test/horde/lib/Horde/IMAP/Tree.php on line 1094
[Wed Mar 23 20:33:02 2005] [error] PHP Notice:                val =
stdClass Object
(
    [name] => INBOX
    [attributes] => 1
    [delimiter] =>
    [fullServerPath] => {66.165.106.126:143/imap/notls}INBOX
)

 in /home/www/test/horde/lib/Horde/IMAP/Tree.php on line 1097
------------------------------------------------------------------------

Currently I have coded a very simple workaround hack.  I know none of my
users should have subfolders of the INBOX, so I have just simply changed the
"if ($expandall || $this->isOpen($elt))" test to "if (($expandall ||
$this->isOpen($elt)) && $elt['v'] !== 'INBOX')".  It works right now - but I
beg of someone who knows better to help me come up with a proper fix! :)

Eli.




More information about the imp mailing list