php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64469 Constructing a DateTimeZone object with an invalid tz name emits a hidden error
Submitted: 2013-03-20 16:40 UTC Modified: 2013-03-22 04:08 UTC
From: evert at rooftopsolutions dot nl Assigned:
Status: Not a bug Package: date_time (PECL)
PHP Version: 5.4.13 OS: Any
Private report: No CVE-ID: None
 [2013-03-20 16:40 UTC] evert at rooftopsolutions dot nl
Description:
------------
When creating a new DateTimeZone with an invalid tz name, the documentation states that it will emit an exception.

This happens, however.. a notice is also emitted, although not immediately visible. This notice pops its head up when calling error_get_last().

Test script:
---------------
php -d error_reporting=-1 -d display_errors=1  -r ' try { @new DateTimeZone("YOUR MOM"); } catch (Exception $e) {} print_r( error_get_last() ); ';

Expected result:
----------------
NULL

Actual result:
--------------
Array
(
    [type] => 2
    [message] => DateTimeZone::__construct(): Unknown or bad timezone (YOUR MOM)
    [file] => Command line code
    [line] => 1
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-03-22 04:08 UTC] laruence@php.net
-Status: Open +Status: Not a bug
 [2013-03-22 04:08 UTC] laruence@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Date ext use EH_THROW as a error callback to trigger exceptions.

that means, it first is an error, then bubble up in exception form.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 07:01:26 2019 UTC