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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: daniel dot oconnor at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 14:01:36 2025 UTC