Bug #74940 [Asn->Csd]: DateTimeZone loose comparison always true until properties are initialized.
| From: | cmb@php.net | Date: | Mon, 30 Mar 2020 07:18:42 +0000 |
| Subject: | Bug #74940 [Asn->Csd]: DateTimeZone loose comparison always true until properties are initialized. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-226334@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74940&edit=1
ID: 74940
Updated by: cmb@php.net
Reported by: arjen at parse dot nl
Summary: DateTimeZone loose comparison always true until
properties are initialized.
-Status: Assigned
+Status: Closed
Type: Bug
Package: Date/time related
Operating System: irrelevant
PHP Version: 7.0
Assigned To: jhdxr
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=a2f8c78183a5911bc5a923956ff531b6d27cff2a
Log: Fix #74940: DateTimeZone loose comparison always true
Previous Comments:
------------------------------------------------------------------------
[2020-03-02 13:36:27] cmb@php.net
The following pull request has been associated:
Patch Name: Fix #74940: DateTimeZone loose comparison always true
On GitHub: https://github.com/php/php-src/pull/5227
Patch: https://github.com/php/php-src/pull/5227.patch
------------------------------------------------------------------------
[2018-12-04 23:04:14] a at b dot c dot de
Related To: Bug #77202
------------------------------------------------------------------------
[2017-08-13 14:43:18] jhdxr@php.net
var_dump will call get_properties, which updates properties inside the
object.
------------------------------------------------------------------------
[2017-07-22 05:53:01] heiglandreas@php.net
That seems to be related to the issue with setting internal variables on var_Dump. But from my POV
it should definitely evaluate to false in ALL cases when the timezones mismatch.
------------------------------------------------------------------------
[2017-07-17 12:52:17] arjen at parse dot nl
Description:
------------
When using the loose equal comparision, the result is always true when the internal DateTimeZone
properties have not been initialized yet.
Properties have to be 'initialized' by var_dump'ing the objects.
See https://3v4l.org/EQ1AG#v720alpha3
Test script:
---------------
<?php
$tz = new DateTimeZone('Europe/Amsterdam');
$utc = new DateTimeZone('UTC');
var_dump($tz == $utc);
var_dump($tz === $utc);
var_dump($tz, $utc);
var_dump($tz == $utc);
var_dump($tz === $utc);
Expected result:
----------------
bool(false)
bool(false)
object(DateTimeZone)#1 (2) {
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
object(DateTimeZone)#2 (2) {
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
bool(false)
bool(false)
Actual result:
--------------
bool(true)
bool(false)
object(DateTimeZone)#1 (2) {
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
object(DateTimeZone)#2 (2) {
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
bool(false)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74940&edit=1