php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #60738
Patch bug60738.patch revision 2012-03-24 04:17 UTC by laruence@php.net
revision 2012-03-24 03:32 UTC by laruence@php.net
revision 2012-03-24 03:30 UTC by laruence@php.net
revision 2012-03-24 03:24 UTC by laruence@php.net
Patch error_handler_patch_1.diff revision 2012-03-23 20:50 UTC by nikic@php.net
Patch set_error_handler-allow-null-parameter-corrected revision 2012-03-11 07:46 UTC by kevin dot swinton at gmail dot com
Patch set_error_handler-allow-null-parameter revision 2012-03-10 22:34 UTC by kevin dot swinton at gmail dot com

Patch bug60738.patch for Unknown/Other Function Bug #60738

Patch version 2012-03-24 03:24 UTC

Return to Bug #60738 | Download this patch
This patch is obsolete

Obsoleted by patches:

Patch Revisions:

Developer: laruence@php.net

diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index b55231d..e5ae594 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1512,7 +1512,6 @@ 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;
 
@@ -1520,37 +1519,45 @@ ZEND_FUNCTION(set_error_handler)
 		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");
+	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;
+		}
 		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));
+		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));
+		}
 
-	if (!zend_is_true(error_handler)) { /* unset user-defined handler */
-		FREE_ZVAL(EG(user_error_handler));
-		EG(user_error_handler) = NULL;
-		RETURN_TRUE;
-	}
+		ALLOC_ZVAL(EG(user_error_handler));
+		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));
 
-	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();
+		}
+	} else { /* unset user-defined handler */
+		if (EG(user_error_handler)) {
+			*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));
+		}
 
-	if (!had_orig_error_handler) {
-		RETURN_NULL();
+		EG(user_error_handler) = NULL;
+		RETURN_TRUE;
 	}
 }
 /* }}} */
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC