From: Dmitry Stogov Date: Tue, 26 Apr 2005 08:47:31 +0000 (+0000) Subject: Fixed bug #32429 (method_exists() always return TRUE if __call method exists) X-Git-Tag: php-5.0.1b1~412 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4f15b20b92e89e78a3bae4e48838ad1e534f7868;p=php Fixed bug #32429 (method_exists() always return TRUE if __call method exists) --- diff --git a/NEWS b/NEWS index 7b69b76d6a..4cec0987a9 100644 --- a/NEWS +++ b/NEWS @@ -109,6 +109,8 @@ PHP NEWS - Fixed ZTS destruction. (Marcus) - Fixed bug #32491 (File upload error - unable to create a temporary file). (Uwe Schindler) +- Fixed bug #32429 (method_exists() always return TRUE if __call method + exists). (Dmitry) - Fixed bug #32109 ($_POST is not populated in multithreaded environment). (Moriyoshi) - Fixed bug #31478 (segfault with empty() / isset()). (Moriyoshi) diff --git a/Zend/tests/bug32429.phpt b/Zend/tests/bug32429.phpt new file mode 100644 index 0000000000..db5dc7d90a --- /dev/null +++ b/Zend/tests/bug32429.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #32429 (method_exists() always return TRUE if __call method exists) +--FILE-- +test(); + } + } + + public function __call($name, $args) { + throw new Exception('Call to undefined method'.get_class($this).'::'.$name.'()'); + } +} + +try { + $test = new TestClass; +} catch (Exception $e) { + exit($e->getMessage()); +} + +?> +--EXPEXT-- +bool(false) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index efb4467c38..d5604c447b 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -880,11 +880,20 @@ ZEND_FUNCTION(method_exists) efree(lcname); RETURN_TRUE; } else { + union _zend_function *func = NULL; efree(lcname); + if (Z_TYPE_PP(klass) == IS_OBJECT && Z_OBJ_HT_PP(klass)->get_method != NULL - && Z_OBJ_HT_PP(klass)->get_method(klass, Z_STRVAL_PP(method_name), Z_STRLEN_PP(method_name) TSRMLS_CC) != NULL + && (func = Z_OBJ_HT_PP(klass)->get_method(klass, Z_STRVAL_PP(method_name), Z_STRLEN_PP(method_name) TSRMLS_CC)) != NULL ) { + if (func->type == ZEND_INTERNAL_FUNCTION + && ((zend_internal_function*)func)->handler == zend_std_call_user_call + ) { + efree(((zend_internal_function*)func)->function_name); + efree(func); + RETURN_FALSE; + } RETURN_TRUE; } }