Issues

ZF-11573: countMessages() on empty Mailbox causes warning: 'invalid argument supllied for foreach()' in Zend_Mail_Protocol_Imap line 829

Issue Type: Bug Created: 2011-07-18T14:09:11.000+0000 Last Updated: 2011-07-18T14:09:11.000+0000 Status: Open Fix version(s): Reporter: Wolf Nils Bartels (wolfnilson) Assignee: Dolf Schimmel (Freeaqingme) (freak) Tags: - Zend_Mail_Storage

  • zend_mail_storage_imap

Related issues: Attachments:

Description

this code of mine:

<pre class="literal">
    $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:

<pre class="literal">
    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

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts