Zend Framework

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

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.5.1
  • Fix Version/s: 1.6.0
  • Component/s: Zend_Mail
  • Labels:
    None

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.

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

this will eventually end up calling the following code

Zend_Mail_Protocol_Imap::list
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.

Activity

Hide
Wil Sinclair added a comment -

Please evaluate and categorize/assign as necessary.

Show
Wil Sinclair added a comment - Please evaluate and categorize/assign as necessary.
Hide
Nico Edtinger added a comment -

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

Show
Nico Edtinger added a comment - Good catch. It seems a bit strange, that you don't get an error with an invalid reference, but it's now checked.
Hide
Wil Sinclair added a comment -

Updating for the 1.6.0 release.

Show
Wil Sinclair added a comment - Updating for the 1.6.0 release.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: