#26883 [Asn->Csd]: [suggestion] 2nd argument for set_error_handler to speed up performance
| From: | zeev@php.net | Date: | Thu, 15 Jan 2004 16:42:34 +0000 |
| Subject: | #26883 [Asn->Csd]: [suggestion] 2nd argument for set_error_handler to speed up performance | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-53394@lists.php.net to get a copy of this message | ||
ID: 26883
Updated by: zeev@php.net
Reported By: xuefer at 21cn dot com
-Status: Assigned
+Status: Closed
Bug Type: Feature/Change Request
Operating System: *
PHP Version: 5CVS-2004-01-12 (dev)
Assigned To: zeev
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2004-01-14 10:43:46] sniper@php.net
Zeev, can you look at this please.
------------------------------------------------------------------------
[2004-01-14 06:42:46] xuefer at 21cn dot com
opening, because:
http://cvs.php.net/co.php/php-src/ChangeLog?login=2&r=1.1506
* ZendEngine2/zend_builtin_functions.c
ZendEngine2/zend_execute_API.c
ZendEngine2/zend_globals.h
ZendEngine2/zend_operators.c:
Added error mask to set_error_handler()
Patch by Christian Schneider <cschneid@cschneid.com>
zend.c is not modified, i.e.: error mask is not in use
------------------------------------------------------------------------
[2004-01-12 10:36:50] xuefer at 21cn dot com
eh? sorry, but i don't see the changes?
my recommend change is for zend.c
http://cvs.php.net/cvs.php/ZendEngine2/zend.c?login=2
what i said "this change require" means those patch should not be
revert because of this feature request
------------------------------------------------------------------------
[2004-01-12 10:04:00] sniper@php.net
Already done:
revision 1.222
date: 2004/01/10 11:43:41; author: zeev; state: Exp; lines: +13 -8
Added error mask to set_error_handler()
Patch by Christian Schneider <cschneid@cschneid.com>
------------------------------------------------------------------------
[2004-01-12 08:58:18] xuefer at 21cn dot com
Description:
------------
the idea is from the internals mailinglist recently that discuss about
2nd argument for set_error_handler.
it seems error mask is not going to be used, as i saw no changes in
zend.c function zend_error()
but i'm talking about performance here.
many php scripters use:
$page = (int) @ $_GET['page'];
$id = (int) @ $_GET['id'];
etc etc..
and they use set_error_handler('myErrorHandler');
and
function myErrorHandler($errstr, $errno, ...)
{
if (! (error_reporting() & $errno) ) {
return;
}
..
}
for just every undefined index of page/id
bunch of code in zend_error() is executed and then user defined
function "myErrorHandler", and then error_reporting()
callback set_error_handler(callback handler, [int error_mask]);
error_mask default to NULL(or 0), means "don't check with mask", which
is BackCompat with old scripts
for most scripters, use
set_error_handler('myErrorHandler', E_ALL);
and (error_reporting() & $error_mask) is check BEFORE calling
myErrorHandler
===== change ===
/* if we don't have a user defined error handler */
if (!EG(user_error_handler)) {
zend_error_cb(type, error_filename, error_lineno, format, args);
} else switch (type) {
==== into ====
/* if we don't have a user defined error handler */
if (!EG(user_error_handler)
|| !EG(user_error_handler_error_reporting)
|| !((EG(user_error_handler_error_reporting) & type)) {
zend_error_cb(type, error_filename, error_lineno, format, args);
} else switch (type) {
this change require:
http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?login=2&r1=1.221&r2=1.222&ty=h
Last Log Message for rev 1.222:
Added error mask to set_error_handler()
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26883&edit=1