From fc17bfaacfd48b3952652792bf684ff223499678 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 8 Aug 2019 09:55:29 +0200 Subject: [PATCH] Fixed bug #78383 --- NEWS | 3 +++ ext/date/php_date.c | 2 ++ ext/date/tests/bug78383.phpt | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 ext/date/tests/bug78383.phpt diff --git a/NEWS b/NEWS index 997e19c95c..21c109430f 100644 --- 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 diff --git a/ext/date/php_date.c b/ext/date/php_date.c index e7c68954bb..7898a05ca7 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -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 index 0000000000..78d4617fb0 --- /dev/null +++ b/ext/date/tests/bug78383.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #78383: Casting a DateTime to array no longer returns its properties +--FILE-- + +--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" +} -- 2.40.0