From 2d21149743c8ef52e5fdf62da18a1a903c09670a Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Sat, 24 Mar 2012 19:25:21 +0800 Subject: [PATCH 1/3] Revert "Merge from PHP-5.4" This reverts commit 9a87fe1c529eabc7aeec4559d916dda5fda3cdd2. --- Zend/zend_builtin_functions.c | 37 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index c4a10fde37..ce54f4ee27 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1488,42 +1488,41 @@ 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)); - } + 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)); - ALLOC_ZVAL(EG(user_exception_handler)); - MAKE_COPY_ZVAL(&exception_handler, 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)); - } + if (Z_TYPE_P(exception_handler) == IS_NULL) { /* unset user-defined handler */ + FREE_ZVAL(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(); + } } /* }}} */ From 9c99a89e8e2f740b96e3f8b423c0ce6702cc3be6 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Sat, 24 Mar 2012 19:26:02 +0800 Subject: [PATCH 2/3] Revert "Implemented FR #60738 (Allow 'set_error_handler' to handle NULL)" This reverts commit fcae164ea63979d7814d7aa114fe8351033e7400. --- NEWS | 2 -- Zend/tests/bug60738.phpt | 17 ----------- Zend/zend_builtin_functions.c | 56 +++++++++++++++++------------------ 3 files changed, 27 insertions(+), 48 deletions(-) delete mode 100644 Zend/tests/bug60738.phpt diff --git a/NEWS b/NEWS index 2e1dd7c438..fa36358231 100644 --- a/NEWS +++ b/NEWS @@ -23,8 +23,6 @@ PHP NEWS . Fixed bug #60825 (Segfault when running symfony 2 tests). (Dmitry, Laruence) . Fixed bug #60801 (strpbrk() mishandles NUL byte). (Adam) - . Implemented FR #60738 (Allow 'set_error_handler' to handle NULL). - (Laruence, Nikita Popov) . Fixed bug #60569 (Nullbyte truncates Exception $message). (Ilia) . Fixed bug #60227 (header() cannot detect the multi-line header with CR). (rui, Gustavo) 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-- - ---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(); + } } /* }}} */ From 5a0b3cc90a5ff059a812d7de27312d07292f1f77 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Sat, 24 Mar 2012 19:27:00 +0800 Subject: [PATCH 3/3] Revert "Update NEWS" This reverts commit 88a8085aa3ae4ce3928d0309a3c5530e7483a134. --- NEWS | 2 -- 1 file changed, 2 deletions(-) diff --git a/NEWS b/NEWS index 753c348af5..7853ad6cc8 100644 --- a/NEWS +++ b/NEWS @@ -33,8 +33,6 @@ PHP NEWS . Fixed bug #60801 (strpbrk() mishandles NUL byte). (Adam) . Fixed bug #60717 (Order of traits in use statement can cause a fatal error). (Stefan) - . Implemented FR #60738 (Allow 'set_error_handler' to handle NULL). - (Laruence, Nikita Popov) . Fixed bug #60573 (type hinting with "self" keyword causes weird errors). (Laruence) . Fixed bug #60569 (Nullbyte truncates Exception $message). (Ilia)