Issues

ZF-7589: Zend_Date::setDate when parsing the date to set in an array

Description

Using Zend_Date::setDate with the date to set in an array throws an exception in Zend/Date.php, line 2846 due to the use of an undefined variable in the if clause.

The simple test below demonstrates the problem.

The expected result of this test is to pass, the actual result is a Zend_Date_Exception with the message "no day,month or year given in array".


public function testSetDateWithArray()
{
    $locale = new Zend_Locale('en-US');
    $date = new Zend_Date(1234567890, null, $locale);

    $array = array('year' => 2009, 'month' => 8, 'day' => 14);
    $result = $date->setDate($array, null, $locale);

    $this->assertSame('2009-08-14T04:31:30+05:00', $result->get(Zend_Date::W3C));
}

Comments

This patch contains a fix for the problem and the test to verify its correctness.

Fixed with r17607