Bug #65787 [NEW]: DateTime::__construct() accepts all single letters except 'j' as valid timezone
| From: | vascowhite at gmail dot com | Date: | Sun, 29 Sep 2013 15:13:43 +0000 |
| Subject: | Bug #65787 [NEW]: DateTime::__construct() accepts all single letters except 'j' as valid timezone | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-181823@lists.php.net to get a copy of this message | ||
From: vascowhite at gmail dot com
Operating system: All?
PHP version: 5.5.4
Package: Date/time related
Bug Type: Bug
Bug description:DateTime::__construct() accepts all single letters except 'j' as valid
timezone
Description:
------------
If just a single letter is passed to the constructor of \DateTime it is
accepted
as a valid timezone string. Except, for some strange reason, the letter
'j'.
Test script:
---------------
$date = new \DateTime('a');
var_dump($date);
Expected result:
----------------
I expect an exception to be raised with the message:-
Fatal error: Uncaught exception 'Exception' with message
'DateTime::__construct():
Failed to parse time string (a) at position 0 (a): The timezone could not
be found
in the database'
Actual result:
--------------
Except for when the letter 'j' is passed a DateTime object is created. For
example
the following code:-
$date = new \DateTime('a');
var_dump($date);
Will give the following output:-
object(DateTime)[1]
public 'date' => string '2013-09-29 15:17:19' (length=19)
public 'timezone_type' => int 2
public 'timezone' => string 'A' (length=1)
Where it should raise an exception.
--
Edit bug report at https://bugs.php.net/bug.php?id=65787&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65787&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=65787&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65787&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=65787&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=65787&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65787&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=65787&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=65787&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=65787&r=support
Expected behavior: https://bugs.php.net/fix.php?id=65787&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=65787&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=65787&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=65787&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65787&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=65787&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=65787&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=65787&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65787&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65787&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=65787&r=mysqlcfg