summaryrefslogtreecommitdiff
path: root/Zend/zend_builtin_functions.c
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>2000-06-12 20:31:02 +0000
committerZeev Suraski <zeev@php.net>2000-06-12 20:31:02 +0000
commite962769fee59a723b53c26c0331ecc855e724e66 (patch)
treed3b6d435def741b0d8d0cf534d3952b67189ec34 /Zend/zend_builtin_functions.c
parent61c0f610dc1426827d11cc5ab69de1a418b799ea (diff)
downloadphp-git-e962769fee59a723b53c26c0331ecc855e724e66.tar.gz
Return the previous error handler from set_error_handler()
Diffstat (limited to 'Zend/zend_builtin_functions.c')
-rw-r--r--Zend/zend_builtin_functions.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 0c3d48eac9..f0ca2cc4ec 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -755,11 +755,13 @@ ZEND_FUNCTION(trigger_error)
/* }}} */
-/* {{{ proto int set_error_handler(string error_handler)
- Sets a user-defined error handler function */
+/* {{{ proto string set_error_handler(string error_handler)
+ Sets a user-defined error handler function. Returns the previously defined
+ error handler, or false on error */
ZEND_FUNCTION(set_error_handler)
{
zval **error_handler;
+ zend_bool had_orig_error_handler=0;
if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &error_handler)==FAILURE) {
ZEND_WRONG_PARAM_COUNT();
@@ -767,7 +769,8 @@ ZEND_FUNCTION(set_error_handler)
convert_to_string_ex(error_handler);
if (EG(user_error_handler)) {
- zval_dtor(EG(user_error_handler));
+ had_orig_error_handler = 1;
+ *return_value = *EG(user_error_handler);
} else {
ALLOC_ZVAL(EG(user_error_handler));
}
@@ -781,7 +784,9 @@ ZEND_FUNCTION(set_error_handler)
*EG(user_error_handler) = **error_handler;
zval_copy_ctor(EG(user_error_handler));
- RETURN_TRUE;
+ if (!had_orig_error_handler) {
+ RETURN_STRINGL("", 0, 1);
+ }
}
/* }}} */