com php-src: Fixed bug #74657 (Undefined constants in array properties result in broken properties): NEWS Zend/tests/bug74657.phpt Zend/zend_API.c
| From: | Xinchen Hui | Date: | Sat, 27 May 2017 04:06:43 +0000 |
| Subject: | com php-src: Fixed bug #74657 (Undefined constants in array properties result in broken properties): NEWS Zend/tests/bug74657.phpt Zend/zend_API.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-97893@lists.php.net to get a copy of this message | ||
Commit: 5269c4cacbc1372341d2091337d87fa3b0181490
Author: Xinchen Hui <laruence@gmail.com> Sat, 27 May 2017 12:06:43 +0800
Parents: 872e43d6e55e4af84681b259198ee688287cd40d
Branches: PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5269c4cacbc1372341d2091337d87fa3b0181490
Log:
Fixed bug #74657 (Undefined constants in array properties result in broken properties)
Bugs:
https://bugs.php.net/74657
Changed paths:
M NEWS
A Zend/tests/bug74657.phpt
M Zend/zend_API.c
Diff:
diff --git a/NEWS b/NEWS
index daab8dc..484e684 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 0000000..41e28ce
--- /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 4fee752..4f9f4f9 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;
}
/* }}} */