ZF-3095: Zend_Mail_Protocol_Imap::listMailbox - Invalid argument supplied for foreach()


Appears that calling Zend_Mail_Storage_Imap::getFolders with an invalid parameter will cause a PHP warning to be thrown as Zend_Mail_Protocol_Imap will attempt to iterate over a boolean value.

$mail = new Zend_Mail_Storage_Imap(array(..., 'ssl' => 'SSL'));
$folders = $mail->getFolders('DoesNotExist');

this will eventually end up calling the following code

    public function listMailbox($reference = '', $mailbox = '*')
        $result = array();
        $list = $this->requestAndResponse('LIST', $this->escapeString($reference, $mailbox));
        if (!$list) {
            return $result;

        foreach ($list as $item) {
            if (count($item) != 4 || $item[0] != 'LIST') {
            $result[$item[3]] = array('delim' => $item[2], 'flags' => $item[1]);

        return $result;

Which will cause a PHP Warning when it tries to loop through $list as $list is a {{bool(true)}} and not an array.


Please evaluate and categorize/assign as necessary.

Good catch. It seems a bit strange, that you don't get an error with an invalid reference, but it's now checked.

Updating for the 1.6.0 release.