set_error_handler and set_exception_handler behavior
| From: | Nikita Popov | Date: | Sat, 24 Mar 2012 13:26:37 +0000 |
| Subject: | set_error_handler and set_exception_handler behavior | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-59147@lists.php.net to get a copy of this message | ||
Hi internals!
Laruence and myself yesterday tried to slightly modify the
set_error_handler behavior, but the change which we considered trivial
was not perceived as such by others. So we are taking this to the ML.
Current state of things:
* set_error_handler(callback) and set_exception_handler(callback)
will return the previous error/exception handler
* set_exception_handler(NULL) will reset the exception handler (i.e.
use the default PHP exception handler again) and return bool(true)
* set_error_handler(NULL) throws an invalid argument error => inconsistent
What we wanted to do:
Allow the error handler being reset using set_error_handler(NULL). To
be consistent with set_exception_handler(NULL) this was supposed to
return bool(true).
What people objected to:
* Stas: The bool(true) return value does not really make sense.
Instead the previous error/exception handler should be returned, as
always.
* Pierre: One shouldn't be able to reset the error/exception handler
like that in any case. This behavior should be removed and instead
there should be additional reset_error_handler() and
reset_exception_handler() functions (and also get_error_handler() and
get_exception_handler() if I got that right.)
What I would do:
Add support for set_error_handler(NULL) and change the return value
of set_error_handler(NULL)+set_exception_handler(NULL) to the previous
handler (i.e. Stas option). I implemented this option in this PR:
https://github.com/php/php-src/pull/20
So, what are your opinions on this?
Nikita