php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26883 [suggestion] 2nd argument for set_error_handler to speed up performance
Submitted: 2004-01-12 08:58 UTC Modified: 2004-01-16 04:59 UTC
From: xuefer at 21cn dot com Assigned: zeev (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2004-01-12 (dev) OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: xuefer at 21cn dot com
New email:
PHP Version: OS:

 

 [2004-01-12 08:58 UTC] 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()



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-12 10:04 UTC] 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 10:36 UTC] 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-14 06:42 UTC] 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-14 10:43 UTC] sniper@php.net
Zeev, can you look at this please.

 [2004-01-15 11:42 UTC] zeev@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 06:01:28 2024 UTC