diff options
| author | Zeev Suraski <zeev@php.net> | 2000-06-17 18:04:58 +0000 |
|---|---|---|
| committer | Zeev Suraski <zeev@php.net> | 2000-06-17 18:04:58 +0000 |
| commit | 34c2b0a07c5cbd5c7ea506a1891b9264c15631d0 (patch) | |
| tree | 9934a803c4c8388742bedfccb160828a6c623cdf /Zend/zend_builtin_functions.c | |
| parent | 66f1be08c8d8b437e0395ea6153664a7aa25fc7f (diff) | |
| download | php-git-34c2b0a07c5cbd5c7ea506a1891b9264c15631d0.tar.gz | |
- Add restore_error_handler()
error_handler's are now stored in a stack
Diffstat (limited to 'Zend/zend_builtin_functions.c')
| -rw-r--r-- | Zend/zend_builtin_functions.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index d9d8ad3973..32ecc6f0b8 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -54,6 +54,7 @@ static ZEND_FUNCTION(get_object_vars); static ZEND_FUNCTION(get_class_methods); static ZEND_FUNCTION(trigger_error); static ZEND_FUNCTION(set_error_handler); +static ZEND_FUNCTION(restore_error_handler); static ZEND_FUNCTION(get_declared_classes); static ZEND_FUNCTION(create_function); #if ZEND_DEBUG @@ -96,6 +97,7 @@ static zend_function_entry builtin_functions[] = { ZEND_FE(trigger_error, NULL) ZEND_FALIAS(user_error, trigger_error, NULL) ZEND_FE(set_error_handler, NULL) + ZEND_FE(restore_error_handler, NULL) ZEND_FE(get_declared_classes, NULL) ZEND_FE(create_function, NULL) #if ZEND_DEBUG @@ -770,9 +772,10 @@ ZEND_FUNCTION(set_error_handler) if (EG(user_error_handler)) { had_orig_error_handler = 1; *return_value = *EG(user_error_handler); - } else { - ALLOC_ZVAL(EG(user_error_handler)); + zval_copy_ctor(return_value); + zend_ptr_stack_push(&EG(user_error_handlers), EG(user_error_handler)); } + ALLOC_ZVAL(EG(user_error_handler)); if (Z_STRLEN_PP(error_handler)==0) { /* unset user-defined handler */ FREE_ZVAL(EG(user_error_handler)); @@ -784,12 +787,29 @@ ZEND_FUNCTION(set_error_handler) zval_copy_ctor(EG(user_error_handler)); if (!had_orig_error_handler) { - RETURN_STRINGL("", 0, 1); + RETURN_NULL(); } } /* }}} */ + +/* {{{ proto void restore_error_handler(void) + Restores the previously defined error handler function */ +ZEND_FUNCTION(restore_error_handler) +{ + if (EG(user_error_handler)) { + zval_ptr_dtor(&EG(user_error_handler)); + } + if (zend_ptr_stack_num_elements(&EG(user_error_handlers))==0) { + EG(user_error_handler) = NULL; + } else { + EG(user_error_handler) = zend_ptr_stack_pop(&EG(user_error_handlers)); + } + RETURN_TRUE; +} + + static int copy_class_name(zend_class_entry *ce, int num_args, va_list args, zend_hash_key *hash_key) { zval *array = va_arg(args, zval *); |
