From dd2876c396eb160a0d90cc03d8ac15d6fd2c396d Mon Sep 17 00:00:00 2001 From: Jani Taskinen Date: Sat, 1 Aug 2009 01:45:22 +0000 Subject: [PATCH] - Fixed bug #49092 (ReflectionFunction fails to work with functions in fully qualified namespaces) --- ext/reflection/php_reflection.c | 16 +++++++++++++++- ext/reflection/tests/bug49092.phpt | 12 ++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 ext/reflection/tests/bug49092.phpt diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index d6973307bb..8f3e6be392 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -1523,8 +1523,22 @@ ZEND_METHOD(reflection_function, __construct) fptr = (zend_function*)zend_get_closure_method_def(closure TSRMLS_CC); Z_ADDREF_P(closure); } else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t", &name_str, &name_len, &type) == SUCCESS) { + zstr nsname; + lcname = zend_u_str_case_fold(type, name_str, name_len, 1, &lcname_len); - if (zend_u_hash_find(EG(function_table), type, lcname, lcname_len + 1, (void **)&fptr) == FAILURE) { + + /* Ignore leading "\" */ + nsname = lcname; + if (lcname.s[0] == '\\') { + if (type == IS_UNICODE) { + nsname.u = &lcname.u[1]; + } else { + nsname.s = &lcname.s[1]; + } + lcname_len--; + } + + if (zend_u_hash_find(EG(function_table), type, nsname, lcname_len + 1, (void **)&fptr) == FAILURE) { efree(lcname.v); zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Function %R() does not exist", type, name_str); diff --git a/ext/reflection/tests/bug49092.phpt b/ext/reflection/tests/bug49092.phpt new file mode 100644 index 0000000000..460a131272 --- /dev/null +++ b/ext/reflection/tests/bug49092.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #49092 (ReflectionFunction fails to work with functions in fully qualified namespaces) +--FILE-- + +--EXPECT-- +Ok -- 2.50.1