From f28c128b207ae2c6ea4d8f6c2e66f5b709210a23 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 24 Mar 2012 13:10:51 +0100 Subject: [PATCH] Return previous error handler when resetting the error handler set_error_handler(null) and set_exception_handler(null) now return the previous error/exception handler instead of just returning bool(true). This is consistent with the behavior of these functions with non-null values. --- Zend/tests/bug60738.phpt | 9 +++++++-- Zend/tests/bug60738_variation.phpt | 23 +++++++++++++++++++++++ Zend/zend_builtin_functions.c | 4 ++-- 3 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 Zend/tests/bug60738_variation.phpt diff --git a/Zend/tests/bug60738.phpt b/Zend/tests/bug60738.phpt index e0c9793fed..e4080715ec 100644 --- a/Zend/tests/bug60738.phpt +++ b/Zend/tests/bug60738.phpt @@ -3,15 +3,20 @@ Bug #60738 Allow 'set_error_handler' to handle NULL --FILE-- --EXPECTF-- +NULL Intercepted error! +object(Closure)#1 (0) { +} Notice: Error! in %s on line %d diff --git a/Zend/tests/bug60738_variation.phpt b/Zend/tests/bug60738_variation.phpt new file mode 100644 index 0000000000..d7cf00ecdb --- /dev/null +++ b/Zend/tests/bug60738_variation.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #60738 Allow 'set_error_handler' to handle NULL +--FILE-- + +--EXPECTF-- +NULL +object(Closure)#1 (0) { +} + +Fatal error: Uncaught exception 'Exception' with message 'Exception!' in %s:%d +Stack trace: +#0 {main} + thrown in %s on line %d + diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 204c7d3d0b..fdfe3db8f8 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1543,7 +1543,7 @@ ZEND_FUNCTION(set_error_handler) if (Z_TYPE_P(error_handler) == IS_NULL) { /* unset user-defined handler */ FREE_ZVAL(EG(user_error_handler)); EG(user_error_handler) = NULL; - RETURN_TRUE; + return; } EG(user_error_handler_error_reporting) = (int)error_type; @@ -1614,7 +1614,7 @@ ZEND_FUNCTION(set_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; + return; } MAKE_COPY_ZVAL(&exception_handler, EG(user_exception_handler)) -- 2.50.1