From 60de74ebdae5cf8b14f85d6e60f519c9e8b966f9 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Mon, 15 Aug 2016 23:22:55 +0800 Subject: [PATCH] Fixed bug #72846 (getConstant for a array constant with constant values returns NULL/NFC/UKNOWN) --- NEWS | 4 +++ ext/reflection/php_reflection.c | 2 ++ ext/reflection/tests/bug72846.phpt | 48 ++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 ext/reflection/tests/bug72846.phpt diff --git a/NEWS b/NEWS index 968a841fff..f58aa0b860 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 964e7a9e57..08acc7e5d2 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 0000000000..ab8b6cac79 --- /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-- +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" +} -- 2.40.0