summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2017-05-27 12:06:43 +0800
committerXinchen Hui <laruence@gmail.com>2017-05-27 12:06:43 +0800
commit5269c4cacbc1372341d2091337d87fa3b0181490 (patch)
tree3ff8ef420714900f1a60a91f2f6938b8d53edc18
parent872e43d6e55e4af84681b259198ee688287cd40d (diff)
downloadphp-git-5269c4cacbc1372341d2091337d87fa3b0181490.tar.gz
Fixed bug #74657 (Undefined constants in array properties result in broken properties)
-rw-r--r--NEWS4
-rw-r--r--Zend/tests/bug74657.phpt26
-rw-r--r--Zend/zend_API.c5
3 files changed, 33 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index daab8dcc33..484e684352 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2017 PHP 7.0.21
+- Core:
+ . Fixed bug #74658 (Undefined constants in array properties result in broken
+ properties). (Laruence)
+
- SPL:
. Fixed bug #74478 (null coalescing operator failing with SplFixedArray).
(jhdxr)
diff --git a/Zend/tests/bug74657.phpt b/Zend/tests/bug74657.phpt
new file mode 100644
index 0000000000..41e28ce58b
--- /dev/null
+++ b/Zend/tests/bug74657.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #74657 (Undefined constants in array properties result in broken properties)
+--FILE--
+<?php
+
+interface I {
+}
+
+class C {
+ const FOO = I::FOO;
+
+ public $options = [self::FOO => "bar"];
+}
+
+try {
+ var_dump((new C)->options);
+} catch (Throwable $e) {}
+
+var_dump((new C)->options);
+?>
+--EXPECTF--
+Fatal error: Uncaught Error: Undefined class constant 'I::FOO' in %sbug74657.php:%d
+Stack trace:
+#0 {main}
+ thrown in %sbug74657.php on line %d
+
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 4fee752df9..4f9f4f9b46 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -1087,8 +1087,6 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties) /* {{{ */
ZEND_API int zend_update_class_constants(zend_class_entry *class_type) /* {{{ */
{
if (!(class_type->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
- class_type->ce_flags |= ZEND_ACC_CONSTANTS_UPDATED;
-
if (class_type->parent) {
if (UNEXPECTED(zend_update_class_constants(class_type->parent) != SUCCESS)) {
return FAILURE;
@@ -1163,6 +1161,9 @@ ZEND_API int zend_update_class_constants(zend_class_entry *class_type) /* {{{ */
*scope = old_scope;
}
}
+
+ class_type->ce_flags |= ZEND_ACC_CONSTANTS_UPDATED;
+
return SUCCESS;
}
/* }}} */