Issues

ZF-2439: Zend_Mail_Storage_Pop3 method getUniqueId does not work properly when there are no messages on the server and UIDL extension is unsupported

Description

The following is the code of the getUniqueId method in Zend_Mail_Storage_Pop3:


public function getUniqueId($id = null)
{   
    if (!$this->hasUniqueid) {
        if ($id) {
            return $id;
        }
        $range = range(1, $this->countMessages());
        return array_combine($range, $range);
    }   

    return $this->_protocol->uniqueid($id);
}

Note the call to the range function. According to the PHP documentation, range() will generate a descending sequence if the 2nd parameter is smaller. The getUniqueId method depends on range returning an empty array if countMessages returns 0, which it does not.

The following code works as intended:


public function getUniqueId($id = null)
{   
    if (!$this->hasUniqueid) {
        if ($id) {
            return $id;
        }

        $numMessages = $this->countMessages();

        if ($numMessages == 0) {
            return array();
        } else {
            $range = range(1, $numMessages);
            return array_combine($range, $range);
        }
    }

    return $this->_protocol->uniqueid($id);
}

NB - I've checked the problem is still present in the trunk.

Comments

No comments to display