Fixed bug #32429 (method_exists() always return TRUE if __call method exists)

This commit is contained in:
Dmitry Stogov 2005-04-26 08:47:31 +00:00
parent 6e0da82528
commit 4f15b20b92
3 changed files with 40 additions and 1 deletions

2
NEWS
View File

@ -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)

28
Zend/tests/bug32429.phpt Normal file
View File

@ -0,0 +1,28 @@
--TEST--
Bug #32429 (method_exists() always return TRUE if __call method exists)
--FILE--
<?php
class TestClass {
public function __construct() {
var_dump(method_exists($this, 'test'));
if (method_exists($this, 'test')) {
$this->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)

View File

@ -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;
}
}