com php-src: Return previous error handler when resetting the error handler: Zend/tests/bug60738.phpt Zend/tests/bug60738 _variation.phpt
Zend/zend_builtin_functions.c

From: Date: Sat, 22 Sep 2012 19:46:18 +0000
Subject: com php-src: Return previous error handler when resetting the error handler: Zend/tests/bug60738.phpt Zend/tests/bug60738 _variation.phpt
Zend/zend_builtin_functions.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-70221@lists.php.net to get a copy of this message
Commit: f28c128b207ae2c6ea4d8f6c2e66f5b709210a23 Author: Nikita Popov <nikic@php.net> Sat, 24 Mar 2012 13:10:51 +0100 Parents: c815dd74bc42c8f36ba35b910f45e85a645d7e3d Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f28c128b207ae2c6ea4d8f6c2e66f5b709210a23 Log: 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. Changed paths: M Zend/tests/bug60738.phpt A Zend/tests/bug60738_variation.phpt M Zend/zend_builtin_functions.c Diff: diff --git a/Zend/tests/bug60738.phpt b/Zend/tests/bug60738.phpt index e0c9793..e408071 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-- <?php -set_error_handler(function() { echo 'Intercepted error!', "\n"; }); +var_dump(set_error_handler( + function() { echo 'Intercepted error!', "\n"; } +)); trigger_error('Error!'); -set_error_handler(null); +var_dump(set_error_handler(null)); trigger_error('Error!'); ?> --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 0000000..d7cf00e --- /dev/null +++ b/Zend/tests/bug60738_variation.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #60738 Allow 'set_error_handler' to handle NULL +--FILE-- +<?php + +var_dump(set_exception_handler( + function() { echo 'Intercepted exception!', "\n"; } +)); + +var_dump(set_exception_handler(null)); + +throw new Exception('Exception!'); +?> +--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 204c7d3...fdfe3db 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))

« previous php.cvs (#70221) next »