From: cataphract
Operating system: Irrelevant
PHP version: 5.3.2
Package: Date/time related
Bug Type: Bug
Bug description:DateTime constructor's second argument doesn't have a null
default value
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 bug report at http://bugs.php.net/bug.php?id=52063&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=52063&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=52063&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=52063&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=52063&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=52063&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=52063&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=52063&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=52063&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=52063&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=52063&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=52063&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=52063&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=52063&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=52063&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52063&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52063&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=52063&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=52063&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=52063&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=52063&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=52063&r=mysqlcfg