diff options
| -rw-r--r-- | NEWS | 4 | ||||
| -rw-r--r-- | Zend/tests/bug74657.phpt | 26 | ||||
| -rw-r--r-- | Zend/zend_API.c | 5 |
3 files changed, 33 insertions, 2 deletions
@@ -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; } /* }}} */ |
