]> granicus.if.org Git - php/commitdiff
Fixed bug #78383
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 8 Aug 2019 07:55:29 +0000 (09:55 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 8 Aug 2019 07:55:52 +0000 (09:55 +0200)
NEWS
ext/date/php_date.c
ext/date/tests/bug78383.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 997e19c95c8a4fa2def67a9891a8522d92cf99b6..21c109430fcee11a76b45f8fd5ccc11bd376edab 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? ????, PHP 7.4.0beta3
 
+- Date:
+  . Fixed bug #78383 (Casting a DateTime to array no longer returns its
+    properties). (Nikita)
 
 08 Aug 2019, PHP 7.4.0beta2
 
index e7c68954bbc3b8b36e40def5174c30b308934a2d..7898a05ca72f3e105744b7485b598f800fa5eda1 100644 (file)
@@ -2293,6 +2293,7 @@ static HashTable *date_object_get_properties_for(zval *object, zend_prop_purpose
                case ZEND_PROP_PURPOSE_SERIALIZE:
                case ZEND_PROP_PURPOSE_VAR_EXPORT:
                case ZEND_PROP_PURPOSE_JSON:
+               case ZEND_PROP_PURPOSE_ARRAY_CAST:
                        break;
                default:
                        return zend_std_get_properties_for(object, purpose);
@@ -2414,6 +2415,7 @@ static HashTable *date_object_get_properties_for_timezone(zval *object, zend_pro
                case ZEND_PROP_PURPOSE_SERIALIZE:
                case ZEND_PROP_PURPOSE_VAR_EXPORT:
                case ZEND_PROP_PURPOSE_JSON:
+               case ZEND_PROP_PURPOSE_ARRAY_CAST:
                        break;
                default:
                        return zend_std_get_properties_for(object, purpose);
diff --git a/ext/date/tests/bug78383.phpt b/ext/date/tests/bug78383.phpt
new file mode 100644 (file)
index 0000000..78d4617
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+Bug #78383: Casting a DateTime to array no longer returns its properties
+--FILE--
+<?php
+
+var_dump((array) new DateTime('2000-01-01'));
+var_dump((array) new DateTimeZone('Europe/Berlin'));
+
+?>
+--EXPECT--
+array(3) {
+  ["date"]=>
+  string(26) "2000-01-01 00:00:00.000000"
+  ["timezone_type"]=>
+  int(3)
+  ["timezone"]=>
+  string(3) "UTC"
+}
+array(2) {
+  ["timezone_type"]=>
+  int(3)
+  ["timezone"]=>
+  string(13) "Europe/Berlin"
+}