php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66985 Some timezones are no longer valid in PHP 5.5.10
Submitted: 2014-03-30 20:13 UTC Modified: 2015-07-07 21:41 UTC
Votes:3
Avg. Score:4.3 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:3 (100.0%)
From: evert at rooftopsolutions dot nl Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.5.10 OS: Any
Private report: No CVE-ID: None
 [2014-03-30 20:13 UTC] evert at rooftopsolutions dot nl
Description:
------------
Sample code attached. Note that this worked before 5.5.10.

Perhaps I took advantage of a feature that was not supposed to be supported, in which case I would definitely appreciate a workaround that works pre and post 5.5.10 :)



Test script:
---------------
php -r "echo (new DateTimeZone('EST5EDT'))->getName();";

Expected result:
----------------
EST5EDT

Actual result:
--------------
Fatal error: Uncaught exception 'Exception' with message 'DateTimeZone::__construct(): Unknown or bad timezone (EST5EDT)' in Command line code on line 1

Exception: DateTimeZone::__construct(): Unknown or bad timezone (EST5EDT) in Command line code on line 1

Call Stack:
    0.0001     221064   1. {main}() Command line code:0
    0.0001     221296   2. DateTimeZone->__construct() Command line code:1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-03-30 22:25 UTC] evert at rooftopsolutions dot nl
Here's a full list of timezones that are not supported on PHP 5.5.10:

CST6CDT
Cuba
Egypt
Eire
EST5EDT
Factory
GB-Eire
GMT0
Greenwich
Hongkong
Iceland
Iran
Israel
Jamaica
Japan
Kwajalein
Libya
MST7MDT
Navajo
NZ-CHAT
Poland
Portugal
PST8PDT
Singapore
Turkey
Universal
W-SU
 [2014-03-31 10:00 UTC] derick@php.net
-Status: Open +Status: Not a bug
 [2014-03-31 10:00 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

You're right. Those no longer work. But you're also right that you used a "feature" that you shouldn't have. Those names are not "timezones", but rather country names (or weird BC entries). It surprises me that they worked in the first place!
 [2014-03-31 14:57 UTC] evert at rooftopsolutions dot nl
Hey Derick,

They worked, because they are part of the olson file, and they are documented on the php site: https://php.net/manual/en/timezones.others.php

Furthermore, I'm using these, not in my code, but because I'm receiving timezone strings from various sources that I can't control. This one came from a c library (libical) from some system that had it's system timezone likely set to EST5EDT.

While I don't disagree that neither I nor anyone else should be using these, you introduced a BC break in a minor PHP version of a documented feature, without as much as a mention in the changelog.

That, to me, sounds like a bug.
 [2014-07-16 14:03 UTC] rasmus@php.net
I agree this shouldn't have been changed in a minor version. For better or worse, there is a lot of EST5EDT and other POSIX tz identifiers out there being used interchangeably with Olson identifiers. If Olson lists it, I think we should support it and if we are going to drop some we should add warnings and in the current version and then drop them only in the next major version.
 [2014-07-16 14:26 UTC] derick@php.net
I don't disagree... but not sure what to do now. It's been four patch releases (or more since) and the discontinuation of those "deprecated identifiers" was a consequence of allowing CEST and the like as argument to a constructor - which there were a few bug reports for. So we can't just revert the patch.

Fixing this is certainly possible, but not as trivial as I hoped when looking into this again. It's still in the back of my head, but I've had some other priorities.
 [2014-07-16 14:30 UTC] rasmus@php.net
-Status: Not a bug +Status: Re-Opened
 [2014-07-16 14:30 UTC] rasmus@php.net
Yup, I looked at it too, I thought it would be as simple as adding them back into the array there, but I see it isn't. The fact that it has been 4 patch releases isn't really an issue though. People are migrating slowly to 5.5 still. For those who are already on current 5.5 they either already fixed this by moving to a more precise tz identifier or they didn't have the problem in the first place, so they won't be affected by the fix. And for the others who aren't there yet it will only help them by removing a compatibility obstacle.
 [2014-07-16 17:01 UTC] evert at rooftopsolutions dot nl
OT: Bit dissapointed that it required a comment from Rasmus for this issue to be as much as acknowledged. Didn't ask for an immediate fix, but getting ignored really sucks.
 [2014-07-18 15:51 UTC] rasmus@php.net
Derick, wouldn't the easiest solution just be to add these to timezonemap.h?
As in, for EST5EDT it would be something like:

{ "edt",   1, -14400, "EST5EDT"                       },
{ "est",   1, -18000, "EST5EDT"                       },
 [2014-07-18 16:04 UTC] derick@php.net
It doesn't work, there are some other bits of code that only let allow through IDs with a / in them. I've moved this to the top of my todo list, so hopefully get to it soon.
 [2014-07-19 00:02 UTC] yohgaki@php.net
Note: JST (Japanese Standard Time) is used to work with older PHP also.
 [2014-07-20 00:43 UTC] rasmus@php.net
Hrm.. In my simple test it worked. It was zone_search() that was failing. With that hack this works fine:

$tz = new DateTimeZone('EST5EDT');
echo $tz->getName()."\n";
$date = new DateTime('2000-01-01', $tz);
$date = $date->modify('+6 months');
echo $date->format('Y-m-d') . "\n";

But true, looking closer at it, $tz->getTranstitions() doesn't return anything.
 [2014-08-17 10:12 UTC] derick@php.net
I have a fix in the works for this. Code works, but need some more test cases and checking for memory leaks.
 [2014-08-17 10:12 UTC] derick@php.net
-Status: Re-Opened +Status: Assigned -Assigned To: +Assigned To: derick
 [2014-08-18 19:28 UTC] derick@php.net
Automatic comment on behalf of github@derickrethans.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=2b9af967fbf12d9eb5fd74a7d6d31431307b0870
Log: Fixed bug #66985: Some timezones are no longer valid in PHP 5.5.10.
 [2014-08-18 19:28 UTC] derick@php.net
-Status: Assigned +Status: Closed
 [2014-10-15 06:49 UTC] gm dot outside+php at gmail dot com
As the fix went in so a minor bug in the test file (ext/date/tests/bug66985.phpt).  Although the test file name itself properly refers to this bug (66985), the very beginning of the file refers to bug #66986 instead.  I believe it was a trivial typo, but it's a bit confusing, so it would be great if somebody could fix that.
 [2015-07-07 21:41 UTC] cmb@php.net
> I believe it was a trivial typo, but it's a bit confusing, so it
> would be great if somebody could fix that.

Thanks for the hint. Fixed now.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 09:01:32 2024 UTC