ZF-3095: Zend_Mail_Protocol_Imap::listMailbox - Invalid argument supplied for foreach()
Description
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') {
continue;
}
$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.
Comments
Posted by Wil Sinclair (wil) on 2008-04-18T15:48:53.000+0000
Please evaluate and categorize/assign as necessary.
Posted by Nico Edtinger (nico) on 2008-04-22T12:05:14.000+0000
Good catch. It seems a bit strange, that you don't get an error with an invalid reference, but it's now checked.
Posted by Wil Sinclair (wil) on 2008-09-02T10:39:05.000+0000
Updating for the 1.6.0 release.