Bug #73239 [NEW]: DateTime constructor throws exceptions when it should not

From: Date: Tue, 04 Oct 2016 13:23:06 +0000
Subject: Bug #73239 [NEW]: DateTime constructor throws exceptions when it should not
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204440@lists.php.net to get a copy of this message
From: alec Operating system: PHP version: 7.0.11 Package: Date/time related Bug Type: Bug Bug description:DateTime constructor throws exceptions when it should not Description: ------------ When invalid (or empty date.timezone) is configured DateTime constructor will throw an exception instead of a warning. On PHP7 I can reproduce the issue with invalid date.timezone. It works with empty date.timezone, but it might be environment specific. I have user reports that it throws exception with empty setting. E.g. PHP Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.' in ... This should not happen.The point of falling back to 'UTC' here is exactly to not throw an exception, no? Test script: --------------- ini_set('date.timezone', 'dummy'); $dt = new DateTime('now'); Expected result: ---------------- no exception. Actual result: -------------- PHP Fatal error: Uncaught Exception: DateTime::__construct(): Invalid date.timezone value 'dummy', we selected the timezone 'UTC' for now. in ... -- Edit bug report at https://bugs.php.net/bug.php?id=73239&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73239&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73239&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73239&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=73239&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=73239&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=73239&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=73239&r=needscript Try newer version: https://bugs.php.net/fix.php?id=73239&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=73239&r=support Expected behavior: https://bugs.php.net/fix.php?id=73239&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=73239&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=73239&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=73239&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73239&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=73239&r=dst IIS Stability: https://bugs.php.net/fix.php?id=73239&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=73239&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=73239&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=73239&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=73239&r=mysqlcfg

« previous php.bugs (#204440) next »