Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:8919 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96305 invoked by uid 1010); 3 Apr 2004 18:18:24 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 96252 invoked from network); 3 Apr 2004 18:18:24 -0000 Received: from unknown (HELO moutng.kundenserver.de) (212.227.126.186) by pb1.pair.com with SMTP; 3 Apr 2004 18:18:24 -0000 Received: from [212.227.126.155] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1B9pip-0006Nd-00 for internals@lists.php.net; Sat, 03 Apr 2004 20:18:23 +0200 Received: from [80.139.19.186] (helo=[80.139.19.186]) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1B9pip-000752-00 for internals@lists.php.net; Sat, 03 Apr 2004 20:18:23 +0200 To: internals@lists.php.net Content-Type: multipart/mixed; boundary="=-jlQBnuCVnxrHfvgVDy9y" Message-ID: <1081016026.868.23.camel@localhost> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Sat, 03 Apr 2004 20:13:46 +0200 X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:e958292ea7b1c44e51b2b9ca0a9da460 Subject: set_exception_handler() From: thekid@thekid.de (Timm Friebe) --=-jlQBnuCVnxrHfvgVDy9y Content-Type: text/plain Content-Transfer-Encoding: 7bit Hello, I wanted to check back on the status of my patch to zend_builtin_functions.c I sent a while ago. It changes set_exception_handler() to accept the pseudo-type "callable" (instead of a string referring to a global function). Examples: set_exception_handler('function_name'); set_exception_handler(array('class_name', 'static_method')); set_exception_handler(array($instance, 'instance_method')); This also makes set_exception_handler() more consistent with all the other callback functionality, e.g. set_error_handler(). Will this patch make it into CVS? - Timm --=-jlQBnuCVnxrHfvgVDy9y Content-Disposition: attachment; filename=zend_set_exception_handler.diff Content-Type: text/x-patch; name=zend_set_exception_handler.diff; charset=iso-8859-1 Content-Transfer-Encoding: 7bit Index: Zend/zend_builtin_functions.c =================================================================== RCS file: /repository/ZendEngine2/zend_builtin_functions.c,v retrieving revision 1.229 diff -u -r1.229 zend_builtin_functions.c --- Zend/zend_builtin_functions.c 1 Apr 2004 22:07:42 -0000 1.229 +++ Zend/zend_builtin_functions.c 3 Apr 2004 17:59:50 -0000 @@ -1009,18 +1009,26 @@ /* }}} */ -/* {{{ proto string set_exception_handler(string exception_handler) +/* {{{ proto string set_exception_handler(callable exception_handler) Sets a user-defined exception handler function. Returns the previously defined exception handler, or false on error */ ZEND_FUNCTION(set_exception_handler) { zval **exception_handler; + char *exception_handler_name = NULL; zend_bool had_orig_exception_handler=0; if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &exception_handler)==FAILURE) { ZEND_WRONG_PARAM_COUNT(); } - convert_to_string_ex(exception_handler); + if (!zend_is_callable(*exception_handler, 0, &exception_handler_name)) { + zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback", + get_active_function_name(TSRMLS_C), exception_handler_name?exception_handler_name:"unknown"); + efree(exception_handler_name); + return; + } + efree(exception_handler_name); + if (EG(user_exception_handler)) { had_orig_exception_handler = 1; *return_value = *EG(user_exception_handler); --=-jlQBnuCVnxrHfvgVDy9y--