summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2012-03-24 14:33:00 +0800
committerXinchen Hui <laruence@gmail.com>2012-03-24 14:33:00 +0800
commit9a87fe1c529eabc7aeec4559d916dda5fda3cdd2 (patch)
tree25474e9e477cba3bec2cdf590dd5fde388e24941
parent56dac369ab930f9f0c42d6cad085868a1ea1a559 (diff)
downloadphp-git-9a87fe1c529eabc7aeec4559d916dda5fda3cdd2.tar.gz
Merge from PHP-5.4
Improve set_exception_handler
-rw-r--r--Zend/zend_builtin_functions.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 8d39a31ad0..57a9e3a7bc 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1486,41 +1486,42 @@ ZEND_FUNCTION(set_exception_handler)
{
zval *exception_handler;
char *exception_handler_name = NULL;
- zend_bool had_orig_exception_handler=0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &exception_handler) == FAILURE) {
return;
}
if (Z_TYPE_P(exception_handler) != IS_NULL) { /* NULL == unset */
+ zend_bool had_orig_exception_handler = 0;
+
if (!zend_is_callable(exception_handler, 0, &exception_handler_name TSRMLS_CC)) {
zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback",
- get_active_function_name(TSRMLS_C), exception_handler_name?exception_handler_name:"unknown");
+ get_active_function_name(TSRMLS_C), exception_handler_name?exception_handler_name:"unknown");
efree(exception_handler_name);
return;
}
efree(exception_handler_name);
- }
- if (EG(user_exception_handler)) {
- had_orig_exception_handler = 1;
- *return_value = *EG(user_exception_handler);
- zval_copy_ctor(return_value);
- zend_ptr_stack_push(&EG(user_exception_handlers), EG(user_exception_handler));
- }
- ALLOC_ZVAL(EG(user_exception_handler));
+ if (EG(user_exception_handler)) {
+ had_orig_exception_handler = 1;
+ *return_value = *EG(user_exception_handler);
+ zval_copy_ctor(return_value);
+ zend_ptr_stack_push(&EG(user_exception_handlers), EG(user_exception_handler));
+ }
+
+ ALLOC_ZVAL(EG(user_exception_handler));
+ MAKE_COPY_ZVAL(&exception_handler, EG(user_exception_handler));
- if (Z_TYPE_P(exception_handler) == IS_NULL) { /* unset user-defined handler */
- FREE_ZVAL(EG(user_exception_handler));
+ if (!had_orig_exception_handler) {
+ RETURN_NULL();
+ }
+ } else {
+ if (EG(user_exception_handler)) {
+ zend_ptr_stack_push(&EG(user_exception_handlers), EG(user_exception_handler));
+ }
EG(user_exception_handler) = NULL;
RETURN_TRUE;
}
-
- MAKE_COPY_ZVAL(&exception_handler, EG(user_exception_handler))
-
- if (!had_orig_exception_handler) {
- RETURN_NULL();
- }
}
/* }}} */