Bug #52063 [Asn->Csd]: DateTime constructor's second argument doesn't have a null default value
| From: | stas@php.net | Date: | Mon, 24 Jan 2011 01:15:57 +0000 |
| Subject: | Bug #52063 [Asn->Csd]: DateTime constructor's second argument doesn't have a null default value | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-158126@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52063&edit=1
ID: 52063
Updated by: stas@php.net
Reported by: cataphract@php.net
Summary: DateTime constructor's second argument doesn't have
a null default value
-Status: Assigned
+Status: Closed
Type: Bug
Package: Date/time related
Operating System: Irrelevant
PHP Version: 5.3.2
Assigned To: derick
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2011-01-24 02:15:43] stas@php.net
Automatic comment from SVN on behalf of stas
Revision: http://svn.php.net/viewvc/?view=revision&revision=307688
Log: Fixed Bug #52063 (DateTime constructor's second argument doesn't
have a null default value)
------------------------------------------------------------------------
[2010-06-12 12:29:03] cataphract@php.net
Description:
------------
DateTime's constructor is documented like this:
public DateTime::__construct ([ string $time = "now" [, DateTimeZone
$timezone = NULL ]] )
However, not passing the constructor the second argument is not the same
as passing NULL. Fixing this is just a matter of adding a "!", like
this
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO",
&time_str, &time_str_len, &timezone_object, date_ce_timezone)) {
into
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO!",
&time_str, &time_str_len, &timezone_object, date_ce_timezone)) {
Test script:
---------------
<?php
date_default_timezone_set("Europe/Lisbon");
$a = new DateTime("2009-01-01", null);
echo $a->format(DateTime::COOKIE);
Expected result:
----------------
Thursday, 01-Jan-09 00:00:00 WET
Actual result:
--------------
Fatal error: Uncaught exception 'Exception' with message
'DateTime::__construct() expects parameter 2 to be DateTimeZone, null
given' in /tmp/cpCZPA42:4 Stack trace: #0 /tmp/cpCZPA42(4):
DateTime->__construct('2009-01-01', NULL) #1 {main} thrown in
/tmp/cpCZPA42 on line 4
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52063&edit=1