Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10114 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19170 invoked by uid 1010); 27 May 2004 15:51:17 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 19103 invoked from network); 27 May 2004 15:51:16 -0000 Received: from unknown (HELO mrout3.yahoo.com) (216.145.54.173) by pb1.pair.com with SMTP; 27 May 2004 15:51:16 -0000 Received: from bourbon.corp.yahoo.com (bourbon.corp.yahoo.com [216.145.53.135]) by mrout3.yahoo.com (8.12.10/8.12.10/y.out) with ESMTP id i4RFon78049719 for ; Thu, 27 May 2004 08:50:49 -0700 (PDT) Received: (from andrei@localhost) by bourbon.corp.yahoo.com (8.12.9/8.11.1) id i4RFomLI037008 for internals@lists.php.net; Thu, 27 May 2004 08:50:48 -0700 (PDT) (envelope-from andrei@gravitonic.com) X-Authentication-Warning: bourbon.corp.yahoo.com: andrei set sender to andrei@gravitonic.com using -f Date: Thu, 27 May 2004 08:50:48 -0700 To: internals@lists.php.net Message-ID: <20040527155047.GA36904@gravitonic.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="opJtzjQTFsWo+cga" Content-Disposition: inline User-Agent: Mutt/1.4.1i Subject: [patch] re-invoking default error handler From: andrei@gravitonic.com (Andrei Zmievski) --opJtzjQTFsWo+cga Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Attached is a small patch that can let you do the following. If you set a custom error handler via set_error_handler() but don't want to implement all the details of handling every single error level, now you can simply handle the ones you are interested. Basically, if you return 1 from your error handler, then the PHP default error handler gets invoked, otherwise nothing happens. So: function my_notice_handler($type, $str, $file, $line, $context) { if ($type == E_NOTICE || $type == E_USER_NOTICE) { /* do something */ return false; } else { /* let PHP default handler do it */ return true; } } It's backwards compatible with previous functionality, i.e. if you don't return anything, the default handler does not get invoked. Do you think it's harmless enough to include in PHP 5? - Andrei --opJtzjQTFsWo+cga Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="default.handler.diff" ? Zend/cscope.out Index: Zend/zend.c =================================================================== RCS file: /repository/Zend/Attic/zend.c,v retrieving revision 1.162.2.18 diff -u -p -r1.162.2.18 zend.c --- Zend/zend.c 8 Apr 2004 16:51:19 -0000 1.162.2.18 +++ Zend/zend.c 26 May 2004 22:38:47 -0000 @@ -812,6 +812,9 @@ ZEND_API void zend_error(int type, const orig_user_error_handler = EG(user_error_handler); EG(user_error_handler) = NULL; if (call_user_function_ex(CG(function_table), NULL, orig_user_error_handler, &retval, 5, params, 1, NULL TSRMLS_CC)==SUCCESS) { + if (zend_is_true(retval)) { + zend_error_cb(type, error_filename, error_lineno, format, args); + } zval_ptr_dtor(&retval); } else { /* The user error handler failed, use built-in error handler */ --opJtzjQTFsWo+cga--