Issue Details (XML | Word | Printable)

Key: ZF-7589
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Thomas Weidner
Reporter: Björn Graf
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Google issue summary
Zend Framework

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

Created: 13/Aug/09 04:04 PM   Updated: 14/Aug/09 02:56 PM   Resolved: 14/Aug/09 02:56 PM
Component/s: Zend_Date
Affects Version/s: None
Fix Version/s: 1.9.2

Time Tracking:
Not Specified

File Attachments: 1. Text File Zend_Date.setDate-with-array.patch (3 kB)



 Description  « Hide

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));
}


Björn Graf added a comment - 13/Aug/09 04:06 PM

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


Björn Graf made changes - 13/Aug/09 04:06 PM
Field Original Value New Value
Attachment Zend_Date.setDate-with-array.patch [ 12140 ]
Satoru Yoshida made changes - 14/Aug/09 07:15 AM
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));
}
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".

{code}
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));
}
{code}
17607 by  Thomas Weidner (2 files)
14/Aug/09 02:41 PM (12 months, 19 days ago)
[ZF-7554, ZF-7589] Zend_Date:

- fix for array handling
- fix for partitial instance creation
Zend_Framework: standard/trunk/library/Zend/Date.php 17607 history download (+5 -5) diffs
Zend_Framework: standard/trunk/tests/Zend/DateTest.php 17607 history download (+11 -2) diffs

Thomas Weidner added a comment - 14/Aug/09 02:55 PM

Fixed with r17607


Thomas Weidner made changes - 14/Aug/09 02:55 PM
Fix Version/s Next Minor Release [ 10360 ]
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Thomas Weidner made changes - 14/Aug/09 02:55 PM
Resolution Fixed [ 1 ]
Status Resolved [ 5 ] Reopened [ 4 ]
Thomas Weidner made changes - 14/Aug/09 02:56 PM
Status Reopened [ 4 ] Resolved [ 5 ]
Fix Version/s Next Mini Release [ 10361 ]
Fix Version/s Next Minor Release [ 10360 ]
Resolution Fixed [ 1 ]
Create crucible review for this changeset in