From 61b3d5ccb525d7524704c42a555a36eb868b803e Mon Sep 17 00:00:00 2001 From: Moriyoshi Koizumi Date: Tue, 26 Nov 2002 21:21:32 +0000 Subject: [PATCH] Fixed incorrect error messages of array_walk() in case the callback is specified in an array form --- ext/standard/array.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/ext/standard/array.c b/ext/standard/array.c index 0ee5f9f8e8..84534e236c 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -980,8 +980,37 @@ static int php_array_walk(HashTable *target_hash, zval **userdata TSRMLS_DC) zval_ptr_dtor(&retval_ptr); } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call %s() - function does not exist", + if (Z_TYPE_PP(BG(array_walk_func_name)) == IS_STRING) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call %s() - function does not exist", (*BG(array_walk_func_name))->value.str.val); + } else if (Z_TYPE_PP(BG(array_walk_func_name)) == IS_ARRAY) { + char *obj_name = NULL; + zval **obj; + zval **mt_name; + + if (zend_hash_index_find(Z_ARRVAL_PP(BG(array_walk_func_name)), + 0, (void **)&obj) == SUCCESS + && zend_hash_index_find(Z_ARRVAL_PP(BG(array_walk_func_name)), + 1, (void **)&mt_name) == SUCCESS + && Z_TYPE_PP(mt_name) == IS_STRING) { + switch (Z_TYPE_PP(obj)) { + case IS_OBJECT: + obj_name = Z_OBJ_PP(obj)->ce->name; + break; + + case IS_STRING: + obj_name = Z_STRVAL_PP(obj); + break; + } + } + + if (obj_name != NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call %s::%s() - function does not exist", + obj_name, Z_STRVAL_PP(mt_name)); + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid function name"); + } + } } zend_hash_move_forward_ex(target_hash, &pos); -- 2.50.1