Bug #17731: [RFC+Patch] Handle parse errors in user-space
| From: | jukkaho at mail dot student dot oulu dot fi | Date: | Wed, 12 Jun 2002 20:01:15 +0000 |
| Subject: | Bug #17731: [RFC+Patch] Handle parse errors in user-space | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-10280@lists.php.net to get a copy of this message | ||
From: jukkaho@mail.student.oulu.fi
Operating system: All
PHP version: 4.2.1
PHP Bug Type: Feature/Change Request
Bug description: [RFC+Patch] Handle parse errors in user-space
I (and apparently many others) needed functionality to handle errors in
include()d files.
I looked into it and by commenting a single line out in Zend/zend.c this
can be archieved with set_error_handler()
--- Zend/zend.c~ Wed Jun 12 22:35:11 2002
+++ Zend/zend.c Wed Jun 12 22:36:01 2002
@@ -682,7 +682,7 @@
zend_error_cb(type, error_filename, error_lineno, format, args);
} else switch (type) {
case E_ERROR:
- case E_PARSE:
+ /* case E_PARSE: User-space can handle this ok. */
case E_CORE_ERROR:
case E_CORE_WARNING:
case E_COMPILE_ERROR:
I have unsuccessfully tried to hang myself with this rope at the moment.
Handler has to be installed before there are any parse errors. It just
won't work other way :). This means that it can't capture any errors in
main level but it can do it for any included file. This also means that
any errors in handler itself or code that installs it can't cause any
recursive loop.
I just can't figure out, how to break things with this (except maybe some
script which expect that no parse errors are sent to the handler)
Perhaps someone of you guys know a way to mess things up if I do this?
There's a comment a few lines below the patch point which says:
/* The error may not be safe to handle in user-space */
and forces zend_error_cb() to handle E_PARSE and other fatal errors.
Perhaps the comment is out of date since there is another comment at the
place where errors are actually handled:
/*case E_PARSE: the parser would return 1 (failure), we can bail out
nicely */
Other fatal errors (E_ERROR,E_COMPILE_ERROR,E_USER_ERROR) cause
zend_bailout() (I don't even know what this function does) etc. but
E_PARSE is handler like any warning or notice there.
So.. is this change safe? If not, what else need's to be changed? I really
like the functionality this tiny patch provides.
--
Edit bug report at http://bugs.php.net/?id=17731&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=17731&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=17731&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=17731&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=17731&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17731&r=support
Expected behavior: http://bugs.php.net/fix.php?id=17731&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=17731&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=17731&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=17731&r=globals