com php-src: Fixed bug #72846 (getConstant for a array constant with constant values returns NULL/NFC/UKNOWN): NEWS ext/reflection/p hp_reflection.c
ext/reflection/tests/bug72846 .phpt

From: Date: Mon, 15 Aug 2016 15:22:55 +0000
Subject: com php-src: Fixed bug #72846 (getConstant for a array constant with constant values returns NULL/NFC/UKNOWN): NEWS ext/reflection/p hp_reflection.c
ext/reflection/tests/bug72846 .phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-93790@lists.php.net to get a copy of this message
Commit: 60de74ebdae5cf8b14f85d6e60f519c9e8b966f9 Author: Xinchen Hui <laruence@gmail.com> Mon, 15 Aug 2016 23:22:55 +0800 Parents: d6b46901b281a3c9d48b65f5f69bae9c7805b118 Branches: PHP-7.0 PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=60de74ebdae5cf8b14f85d6e60f519c9e8b966f9 Log: Fixed bug #72846 (getConstant for a array constant with constant values returns NULL/NFC/UKNOWN) Bugs: https://bugs.php.net/72846 Changed paths: M NEWS M ext/reflection/php_reflection.c A ext/reflection/tests/bug72846.phpt Diff: diff --git a/NEWS b/NEWS index 968a841..f58aa0b 100644 --- a/NEWS +++ b/NEWS @@ -30,6 +30,10 @@ PHP NEWS specifying a sequence). (Pablo Santiago Sánchez, Matteo) . Fixed bug #72759 (Regression in pgo_pgsql). (Anatol) +- Reflection: + . Fixed bug #72846 (getConstant for a array constant with constant values + returns NULL/NFC/UKNOWN). (Laruence) + - Session: . Fixed bug #72724 (PHP7: session-uploadprogress kills httpd). (Nikita) diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 964e7a9..08acc7e 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -4407,6 +4407,7 @@ ZEND_METHOD(reflection_class, getConstants) GET_REFLECTION_OBJECT_PTR(ce); array_init(return_value); ZEND_HASH_FOREACH_VAL(&ce->constants_table, val) { + ZVAL_DEREF(val); if (UNEXPECTED(zval_update_constant_ex(val, 1, ce) != SUCCESS)) { return; } @@ -4431,6 +4432,7 @@ ZEND_METHOD(reflection_class, getConstant) GET_REFLECTION_OBJECT_PTR(ce); ZEND_HASH_FOREACH_VAL(&ce->constants_table, value) { + ZVAL_DEREF(value); if (UNEXPECTED(zval_update_constant_ex(value, 1, ce) != SUCCESS)) { return; } diff --git a/ext/reflection/tests/bug72846.phpt b/ext/reflection/tests/bug72846.phpt new file mode 100644 index 0000000..ab8b6ca --- /dev/null +++ b/ext/reflection/tests/bug72846.phpt @@ -0,0 +1,48 @@ +--TEST-- +Bug #72846 (getConstant for a array constant with constant values returns NULL/NFC/UKNOWN) +--FILE-- +<?php + +namespace Some { + + abstract class A + { + const ONE = '1'; + const TWO = '2'; + + const CONST_NUMBERS = [ + self::ONE, + self::TWO, + ]; + + const NUMBERS = [ + '1', + '2', + ]; + } + + class B extends A + { + } + + $ref = new \ReflectionClass('Some\B'); + + var_dump($ref->getConstant('ONE')); + var_dump($ref->getConstant('CONST_NUMBERS')); + var_dump($ref->getConstant('NUMBERS')); +} +?> +--EXPECT-- +string(1) "1" +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" +}

« previous php.cvs (#93790) next »