ZF-11573: countMessages() on empty Mailbox causes warning: 'invalid argument supllied for foreach()' in Zend_Mail_Protocol_Imap line 829
Description
this code of mine:
$noreply = new Zend_Mail_Storage_Imap(array(
'host' => IMAPSERVER_NOREPLY_HOST,
'user' => IMAPSERVER_NOREPLY_LOGIN,
'password' => IMAPSERVER_NOREPLY_PASSWORD,
'port' => IMAPSERVER_NOREPLY_PORT));
lg('Es liegen '.$noreply->countMessages().' Nachrichten in der Noreply-Mailbox');
led to a warning: 'invalid argument supllied for foreach()' in Zend_Mail_Protocol_Imap line 829 in case that this mailbox contained zero messages. lg() is just my logfile-function to gather Information.
I helped myself, fixing the method in Zend_Mail_Protocol_Imap like this:
public function search(array $params)
{
$response = $this->requestAndResponse('SEARCH', $params);
if (!$response) {
return $response;
}
/* start bugfix */
if (!is_array($response)) $response = array($response);
/* end bugfix */
foreach ($response as $ids) {
if ($ids[0] == 'SEARCH') {
array_shift($ids);
return $ids;
}
}
return array();
}
Comments
No comments to display