Skip to content

Commit 9c99a89

Browse files
committed
Revert "Implemented FR #60738 (Allow 'set_error_handler' to handle NULL)"
This reverts commit fcae164.
1 parent 2d21149 commit 9c99a89

File tree

3 files changed

+27
-48
lines changed

3 files changed

+27
-48
lines changed

NEWS

-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ PHP NEWS
2323
. Fixed bug #60825 (Segfault when running symfony 2 tests).
2424
(Dmitry, Laruence)
2525
. Fixed bug #60801 (strpbrk() mishandles NUL byte). (Adam)
26-
. Implemented FR #60738 (Allow 'set_error_handler' to handle NULL).
27-
(Laruence, Nikita Popov)
2826
. Fixed bug #60569 (Nullbyte truncates Exception $message). (Ilia)
2927
. Fixed bug #60227 (header() cannot detect the multi-line header with CR).
3028
(rui, Gustavo)

Zend/tests/bug60738.phpt

-17
This file was deleted.

Zend/zend_builtin_functions.c

+27-29
Original file line numberDiff line numberDiff line change
@@ -1413,48 +1413,46 @@ ZEND_FUNCTION(trigger_error)
14131413
ZEND_FUNCTION(set_error_handler)
14141414
{
14151415
zval *error_handler;
1416+
zend_bool had_orig_error_handler=0;
14161417
char *error_handler_name = NULL;
14171418
long error_type = E_ALL | E_STRICT;
14181419

14191420
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &error_handler, &error_type) == FAILURE) {
14201421
return;
14211422
}
14221423

1423-
if (IS_NULL != Z_TYPE_P(error_handler)) {
1424-
zend_bool had_orig_error_handler = 0;
1425-
if (!zend_is_callable(error_handler, 0, &error_handler_name TSRMLS_CC)) {
1426-
zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback",
1427-
get_active_function_name(TSRMLS_C), error_handler_name?error_handler_name:"unknown");
1428-
efree(error_handler_name);
1429-
return;
1430-
}
1424+
if (!zend_is_callable(error_handler, 0, &error_handler_name TSRMLS_CC)) {
1425+
zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback",
1426+
get_active_function_name(TSRMLS_C), error_handler_name?error_handler_name:"unknown");
14311427
efree(error_handler_name);
1428+
return;
1429+
}
1430+
efree(error_handler_name);
14321431

1433-
if (EG(user_error_handler)) {
1434-
had_orig_error_handler = 1;
1435-
*return_value = *EG(user_error_handler);
1436-
zval_copy_ctor(return_value);
1437-
INIT_PZVAL(return_value);
1438-
zend_stack_push(&EG(user_error_handlers_error_reporting), &EG(user_error_handler_error_reporting), sizeof(EG(user_error_handler_error_reporting)));
1439-
zend_ptr_stack_push(&EG(user_error_handlers), EG(user_error_handler));
1440-
}
1441-
1442-
ALLOC_ZVAL(EG(user_error_handler));
1443-
EG(user_error_handler_error_reporting) = (int)error_type;
1444-
MAKE_COPY_ZVAL(&error_handler, EG(user_error_handler));
1445-
1446-
if (!had_orig_error_handler) {
1447-
RETURN_NULL();
1448-
}
1449-
} else { /* unset user-defined handler */
1450-
if (EG(user_error_handler)) {
1451-
zend_stack_push(&EG(user_error_handlers_error_reporting), &EG(user_error_handler_error_reporting), sizeof(EG(user_error_handler_error_reporting)));
1452-
zend_ptr_stack_push(&EG(user_error_handlers), EG(user_error_handler));
1453-
}
1432+
if (EG(user_error_handler)) {
1433+
had_orig_error_handler = 1;
1434+
*return_value = *EG(user_error_handler);
1435+
zval_copy_ctor(return_value);
1436+
INIT_PZVAL(return_value);
1437+
zend_stack_push(&EG(user_error_handlers_error_reporting), &EG(user_error_handler_error_reporting), sizeof(EG(user_error_handler_error_reporting)));
1438+
zend_ptr_stack_push(&EG(user_error_handlers), EG(user_error_handler));
1439+
}
1440+
ALLOC_ZVAL(EG(user_error_handler));
14541441

1442+
if (!zend_is_true(error_handler)) { /* unset user-defined handler */
1443+
FREE_ZVAL(EG(user_error_handler));
14551444
EG(user_error_handler) = NULL;
14561445
RETURN_TRUE;
14571446
}
1447+
1448+
EG(user_error_handler_error_reporting) = (int)error_type;
1449+
*EG(user_error_handler) = *error_handler;
1450+
zval_copy_ctor(EG(user_error_handler));
1451+
INIT_PZVAL(EG(user_error_handler));
1452+
1453+
if (!had_orig_error_handler) {
1454+
RETURN_NULL();
1455+
}
14581456
}
14591457
/* }}} */
14601458

0 commit comments

Comments
 (0)