Skip to content

Commit 381c9c1

Browse files
committed
Promote warnings to exceptions in sapi_windows_* functions
1 parent 3b0a190 commit 381c9c1

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

win32/signal.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,22 @@ PHP_FUNCTION(sapi_windows_set_ctrl_handler)
9191
zval *handler = NULL;
9292
zend_bool add = 1;
9393

94+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &handler, &add) == FAILURE) {
95+
return;
96+
}
97+
9498
#if ZTS
9599
if (!tsrm_is_main_thread()) {
96-
php_error_docref(NULL, E_WARNING, "CTRL events can only be received on the main thread");
100+
zend_throw_error(NULL, "CTRL events can only be received on the main thread");
97101
return;
98102
}
99103
#endif
100104

101105
if (!php_win32_console_is_cli_sapi()) {
102-
php_error_docref(NULL, E_WARNING, "CTRL events trapping is only supported on console");
106+
zend_throw_error(NULL, "CTRL events trapping is only supported on console");
103107
return;
104108
}
105109

106-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &handler, &add) == FAILURE) {
107-
return;
108-
}
109110

110111
if (IS_NULL == Z_TYPE_P(handler)) {
111112
zval_dtor(&ctrl_handler);
@@ -118,9 +119,9 @@ PHP_FUNCTION(sapi_windows_set_ctrl_handler)
118119

119120
if (!zend_is_callable(handler, 0, NULL)) {
120121
zend_string *func_name = zend_get_callable_name(handler);
121-
php_error_docref(NULL, E_WARNING, "%s is not a callable function name error", ZSTR_VAL(func_name));
122+
zend_type_error("%s is not a callable function name error", ZSTR_VAL(func_name));
122123
zend_string_release_ex(func_name, 0);
123-
RETURN_FALSE;
124+
return;
124125
}
125126

126127
if (!SetConsoleCtrlHandler(NULL, FALSE) || !SetConsoleCtrlHandler(php_win32_signal_system_ctrl_handler, add)) {
@@ -141,12 +142,12 @@ PHP_FUNCTION(sapi_windows_generate_ctrl_event)
141142
zend_long evt, pid = 0;
142143
zend_bool ret = 0;
143144

144-
if (!php_win32_console_is_cli_sapi()) {
145-
php_error_docref(NULL, E_WARNING, "CTRL events trapping is only supported on console");
145+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|l", &evt, &pid) == FAILURE) {
146146
return;
147147
}
148148

149-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|l", &evt, &pid) == FAILURE) {
149+
if (!php_win32_console_is_cli_sapi()) {
150+
zend_throw_error(NULL, "CTRL events trapping is only supported on console");
150151
return;
151152
}
152153

0 commit comments

Comments
 (0)