diff options
author | Xinchen Hui <laruence@gmail.com> | 2017-05-27 12:09:28 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@gmail.com> | 2017-05-27 12:09:28 +0800 |
commit | 8af21f3ca67042e606ca09a354041b38ca1ad5e5 (patch) | |
tree | 2a8b59de5d84402f5d295abe4f8d1318f161d79a | |
parent | 7b5ba8e68b55dfdbce4cb7fae2b8d9c8a27e94d1 (diff) | |
parent | 63ca6f93a15ce3553edb0a29719811c7a0578026 (diff) | |
download | php-git-8af21f3ca67042e606ca09a354041b38ca1ad5e5.tar.gz |
Merge branch 'PHP-7.1'
* PHP-7.1:
Added NEWs
Fixed bug #74657 (Undefined constants in array properties result in broken properties)
-rw-r--r-- | Zend/tests/bug74657.phpt | 26 | ||||
-rw-r--r-- | Zend/zend_API.c | 5 |
2 files changed, 29 insertions, 2 deletions
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 c95d462872..78985a777a 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1118,8 +1118,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; @@ -1189,6 +1187,9 @@ ZEND_API int zend_update_class_constants(zend_class_entry *class_type) /* {{{ */ } } } + + class_type->ce_flags |= ZEND_ACC_CONSTANTS_UPDATED; + return SUCCESS; } /* }}} */ |