-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed bug #68406 calling var_dump on a DateTimeZone object modifies it
- Loading branch information
Showing
4 changed files
with
93 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--TEST-- | ||
Bug #68406 calling var_dump on a DateTimeZone object modifies it | ||
--INI-- | ||
date.timezone=UTC | ||
--FILE-- | ||
<?php | ||
|
||
$tz1 = new DateTimeZone('Europe/Berlin'); | ||
$tz2 = new DateTimeZone('Europe/Berlin'); | ||
|
||
$d = new DateTime('2014-12-24 13:00:00', $tz1); | ||
var_dump($d->getTimezone(), $tz2); | ||
|
||
if($tz2 == $d->getTimezone()) { | ||
echo "yes"; | ||
} | ||
else { | ||
echo "no"; | ||
} | ||
|
||
--EXPECT-- | ||
object(DateTimeZone)#4 (2) { | ||
["timezone_type"]=> | ||
int(3) | ||
["timezone"]=> | ||
string(13) "Europe/Berlin" | ||
} | ||
object(DateTimeZone)#2 (2) { | ||
["timezone_type"]=> | ||
int(3) | ||
["timezone"]=> | ||
string(13) "Europe/Berlin" | ||
} | ||
yes |
070211b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this change should really be master only. This bug has existed for so long, I'm sure there are people relying on it. I remember seeing some rather dubious code on StackOverflow...
070211b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this is a bug since day 1, and I also run into serveral questions about this, but they are asking why and how to avoid this side effect. I'm curious how people will using this "feature". calling
var_dump
and retrieve$tz->timezone_type
? this value doesn't make sense for userland IMO.