php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44752 Crash with new DateTimeZone(null)
Submitted: 2008-04-17 08:06 UTC Modified: 2008-04-17 10:52 UTC
From: daniel dot oconnor at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.5 OS: Windows XP
Private report: No CVE-ID: None
 [2008-04-17 08:06 UTC] daniel dot oconnor at gmail dot com
Description:
------------
new DateTimeZone crashes apache when given something it can't recognize.

timezone_open is more robust

This has similar symptoms to Bug #43377 ; but is probably different

Reproduce code:
---------------
<?php

$dt = timezone_open("Australia/Adelaide");
var_dump($dt);

$dt = timezone_open("");
var_dump($dt);

$dt = timezone_open(null);
var_dump($dt);

$dt = new DateTimeZone("Australia/Adelaide");
var_dump($dt);

$dt = new DateTimeZone("");
var_dump($dt);

$dt = new DateTimeZone(null);
var_dump($dt);



Expected result:
----------------
object(DateTimeZone)#1 (0) {
}
bool(false)
bool(false)
object(DateTimeZone)#1 (0) {
}
bool(false)
bool(false)


Actual result:
--------------
object(DateTimeZone)#1 (0) {
}
bool(false)
bool(false)
object(DateTimeZone)#1 (0) {
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-17 10:52 UTC] felipe@php.net
Output using 5.2.6:

object(DateTimeZone)#1 (0) {
}

Warning: timezone_open(): Unknown or bad timezone () in ...
bool(false)

Warning: timezone_open(): Unknown or bad timezone () in ...
bool(false)
object(DateTimeZone)#1 (0) {
}

Fatal error: Uncaught exception 'Exception' with message 'DateTimeZone::__construct(): Unknown or bad timezone ()' in ...
Stack trace:
#0 ...(17): DateTimeZone->__construct('')
#1 {main}
  thrown in ...


Then, it looks has been fixed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 09:01:32 2024 UTC