diff options
author | George Peter Banyard <girgias@php.net> | 2020-07-08 18:37:01 +0200 |
---|---|---|
committer | George Peter Banyard <girgias@php.net> | 2020-08-13 21:14:50 +0200 |
commit | dae83cd7cbda51570b660b463cdf13df1cf1e229 (patch) | |
tree | 5d40f2e0e36ee08a7339bf8904cb8bd33aadc782 | |
parent | 9cb522166c64ddb5e161857681e17e820db70255 (diff) | |
download | php-git-dae83cd7cbda51570b660b463cdf13df1cf1e229.tar.gz |
Use ZPP callable check for Windows specific functions
-rwxr-xr-x | ext/standard/basic_functions.stub.php | 4 | ||||
-rwxr-xr-x | ext/standard/basic_functions_arginfo.h | 4 | ||||
-rw-r--r-- | win32/signal.c | 19 |
3 files changed, 11 insertions, 16 deletions
diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index cee18fc086..f3ab8734ea 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -1529,9 +1529,7 @@ function sapi_windows_cp_conv(int|string $in_codepage, int|string $out_codepage, function sapi_windows_cp_is_utf8(): bool {} -/** @param callable|null $handler */ -function sapi_windows_set_ctrl_handler($handler, bool $add = true): bool {} +function sapi_windows_set_ctrl_handler(?callable $handler, bool $add = true): bool {} -/** @param callable|null $handler */ function sapi_windows_generate_ctrl_event(int $event, int $pid = 0): bool {} #endif diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index 535545fdbc..d59c0167de 100755 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 35cb2432b5deea7cff903c2014bce795b4f30209 */ + * Stub hash: 269d4da84e4bc6fae246b90e4c50e48463b86f41 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0) @@ -2229,7 +2229,7 @@ ZEND_END_ARG_INFO() #if defined(PHP_WIN32) ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_sapi_windows_set_ctrl_handler, 0, 1, _IS_BOOL, 0) - ZEND_ARG_INFO(0, handler) + ZEND_ARG_TYPE_INFO(0, handler, IS_CALLABLE, 1) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, add, _IS_BOOL, 0, "true") ZEND_END_ARG_INFO() #endif diff --git a/win32/signal.c b/win32/signal.c index 2436313d2a..41936f840f 100644 --- a/win32/signal.c +++ b/win32/signal.c @@ -87,10 +87,13 @@ static BOOL WINAPI php_win32_signal_system_ctrl_handler(DWORD evt) /* {{{ Assigns a CTRL signal handler to a PHP function */ PHP_FUNCTION(sapi_windows_set_ctrl_handler) { - zval *handler = NULL; + zend_fcall_info fci; + zend_fcall_info_cache fcc; zend_bool add = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &handler, &add) == FAILURE) { + + /* callable argument corresponds to the CTRL handler */ + if (zend_parse_parameters(ZEND_NUM_ARGS(), "f!|b", &fci, &fcc, &add) == FAILURE) { RETURN_THROWS(); } @@ -106,8 +109,7 @@ PHP_FUNCTION(sapi_windows_set_ctrl_handler) RETURN_THROWS(); } - - if (IS_NULL == Z_TYPE_P(handler)) { + if (!ZEND_FCI_INITIALIZED(fci)) { zval_dtor(&ctrl_handler); ZVAL_UNDEF(&ctrl_handler); if (!SetConsoleCtrlHandler(NULL, add)) { @@ -116,20 +118,15 @@ PHP_FUNCTION(sapi_windows_set_ctrl_handler) RETURN_TRUE; } - if (!zend_is_callable(handler, 0, NULL)) { - zend_argument_type_error(1, "must be a valid callable function name"); - RETURN_THROWS(); - } - if (!SetConsoleCtrlHandler(NULL, FALSE) || !SetConsoleCtrlHandler(php_win32_signal_system_ctrl_handler, add)) { - zend_string *func_name = zend_get_callable_name(handler); + zend_string *func_name = zend_get_callable_name(&fci.function_name); php_error_docref(NULL, E_WARNING, "Unable to attach %s as a CTRL handler", ZSTR_VAL(func_name)); zend_string_release_ex(func_name, 0); RETURN_FALSE; } zval_dtor(&ctrl_handler); - ZVAL_COPY(&ctrl_handler, handler); + ZVAL_COPY(&ctrl_handler, &fci.function_name); RETURN_TRUE; }/*}}}*/ |