diff options
author | Xinchen Hui <laruence@gmail.com> | 2012-03-24 19:26:02 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@gmail.com> | 2012-03-24 19:26:02 +0800 |
commit | 9c99a89e8e2f740b96e3f8b423c0ce6702cc3be6 (patch) | |
tree | 7cda38b140075f5f225cdfbed2acd651fa477750 /Zend | |
parent | 2d21149743c8ef52e5fdf62da18a1a903c09670a (diff) | |
download | php-git-9c99a89e8e2f740b96e3f8b423c0ce6702cc3be6.tar.gz |
Revert "Implemented FR #60738 (Allow 'set_error_handler' to handle NULL)"
This reverts commit fcae164ea63979d7814d7aa114fe8351033e7400.
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/tests/bug60738.phpt | 17 | ||||
-rw-r--r-- | Zend/zend_builtin_functions.c | 56 |
2 files changed, 27 insertions, 46 deletions
diff --git a/Zend/tests/bug60738.phpt b/Zend/tests/bug60738.phpt deleted file mode 100644 index e0c9793fed..0000000000 --- a/Zend/tests/bug60738.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Bug #60738 Allow 'set_error_handler' to handle NULL ---FILE-- -<?php - -set_error_handler(function() { echo 'Intercepted error!', "\n"; }); - -trigger_error('Error!'); - -set_error_handler(null); - -trigger_error('Error!'); -?> ---EXPECTF-- -Intercepted error! - -Notice: Error! in %s on line %d diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index ce54f4ee27..8d39a31ad0 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1413,6 +1413,7 @@ ZEND_FUNCTION(trigger_error) ZEND_FUNCTION(set_error_handler) { zval *error_handler; + zend_bool had_orig_error_handler=0; char *error_handler_name = NULL; long error_type = E_ALL | E_STRICT; @@ -1420,41 +1421,38 @@ ZEND_FUNCTION(set_error_handler) return; } - if (IS_NULL != Z_TYPE_P(error_handler)) { - zend_bool had_orig_error_handler = 0; - if (!zend_is_callable(error_handler, 0, &error_handler_name TSRMLS_CC)) { - zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback", - get_active_function_name(TSRMLS_C), error_handler_name?error_handler_name:"unknown"); - efree(error_handler_name); - return; - } + if (!zend_is_callable(error_handler, 0, &error_handler_name TSRMLS_CC)) { + zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback", + get_active_function_name(TSRMLS_C), error_handler_name?error_handler_name:"unknown"); efree(error_handler_name); + return; + } + efree(error_handler_name); - if (EG(user_error_handler)) { - had_orig_error_handler = 1; - *return_value = *EG(user_error_handler); - zval_copy_ctor(return_value); - INIT_PZVAL(return_value); - zend_stack_push(&EG(user_error_handlers_error_reporting), &EG(user_error_handler_error_reporting), sizeof(EG(user_error_handler_error_reporting))); - zend_ptr_stack_push(&EG(user_error_handlers), EG(user_error_handler)); - } - - ALLOC_ZVAL(EG(user_error_handler)); - EG(user_error_handler_error_reporting) = (int)error_type; - MAKE_COPY_ZVAL(&error_handler, EG(user_error_handler)); - - if (!had_orig_error_handler) { - RETURN_NULL(); - } - } else { /* unset user-defined handler */ - if (EG(user_error_handler)) { - zend_stack_push(&EG(user_error_handlers_error_reporting), &EG(user_error_handler_error_reporting), sizeof(EG(user_error_handler_error_reporting))); - zend_ptr_stack_push(&EG(user_error_handlers), EG(user_error_handler)); - } + if (EG(user_error_handler)) { + had_orig_error_handler = 1; + *return_value = *EG(user_error_handler); + zval_copy_ctor(return_value); + INIT_PZVAL(return_value); + zend_stack_push(&EG(user_error_handlers_error_reporting), &EG(user_error_handler_error_reporting), sizeof(EG(user_error_handler_error_reporting))); + zend_ptr_stack_push(&EG(user_error_handlers), EG(user_error_handler)); + } + ALLOC_ZVAL(EG(user_error_handler)); + if (!zend_is_true(error_handler)) { /* unset user-defined handler */ + FREE_ZVAL(EG(user_error_handler)); EG(user_error_handler) = NULL; RETURN_TRUE; } + + EG(user_error_handler_error_reporting) = (int)error_type; + *EG(user_error_handler) = *error_handler; + zval_copy_ctor(EG(user_error_handler)); + INIT_PZVAL(EG(user_error_handler)); + + if (!had_orig_error_handler) { + RETURN_NULL(); + } } /* }}} */ |