From: Máté Kocsis Date: Thu, 14 May 2020 11:31:52 +0000 (+0200) Subject: Add stubs for some SAPIs X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=68527a7834eec98dc33af2fe053c31ce64e745c6;p=php Add stubs for some SAPIs For apache2handler, fpm, litespeed, phpdbg, specifically. Partially implements GH-5295 --- diff --git a/ext/standard/dl.c b/ext/standard/dl.c index 1edfb944fc..ed387761a8 100644 --- a/ext/standard/dl.c +++ b/ext/standard/dl.c @@ -38,7 +38,7 @@ #endif #endif /* defined(HAVE_LIBDL) */ -/* {{{ proto int dl(string extension_filename) +/* {{{ proto bool dl(string extension_filename) Load a PHP extension at runtime */ PHPAPI PHP_FUNCTION(dl) { diff --git a/ext/standard/dl.stub.php b/ext/standard/dl.stub.php new file mode 100644 index 0000000000..d7129141cc --- /dev/null +++ b/ext/standard/dl.stub.php @@ -0,0 +1,3 @@ + #include "fpm.h" +#include "fpm_main_arginfo.h" #include "fpm_request.h" #include "fpm_status.h" #include "fpm_signals.h" @@ -1457,9 +1458,6 @@ static PHP_MINFO_FUNCTION(cgi) } /* }}} */ -ZEND_BEGIN_ARG_INFO(cgi_fcgi_sapi_no_arginfo, 0) -ZEND_END_ARG_INFO() - PHP_FUNCTION(fastcgi_finish_request) /* {{{ */ { fcgi_request *request = (fcgi_request*) SG(server_context); @@ -1510,18 +1508,10 @@ PHP_FUNCTION(fpm_get_status) /* {{{ */ } /* }}} */ -static const zend_function_entry cgi_fcgi_sapi_functions[] = { - PHP_FE(fastcgi_finish_request, cgi_fcgi_sapi_no_arginfo) - PHP_FE(fpm_get_status, cgi_fcgi_sapi_no_arginfo) - PHP_FE(apache_request_headers, cgi_fcgi_sapi_no_arginfo) - PHP_FALIAS(getallheaders, apache_request_headers, cgi_fcgi_sapi_no_arginfo) - PHP_FE_END -}; - static zend_module_entry cgi_module_entry = { STANDARD_MODULE_HEADER, "cgi-fcgi", - cgi_fcgi_sapi_functions, + ext_functions, PHP_MINIT(cgi), PHP_MSHUTDOWN(cgi), NULL, diff --git a/sapi/fpm/fpm/fpm_main.stub.php b/sapi/fpm/fpm/fpm_main.stub.php new file mode 100644 index 0000000000..5d1883c6dd --- /dev/null +++ b/sapi/fpm/fpm/fpm_main.stub.php @@ -0,0 +1,12 @@ + #include @@ -1615,11 +1616,6 @@ int main( int argc, char * argv[] ) /* LiteSpeed PHP module starts here */ -/* {{{ arginfo */ -ZEND_BEGIN_ARG_INFO(arginfo_litespeed__void, 0) -ZEND_END_ARG_INFO() -/* }}} */ - PHP_FUNCTION(litespeed_request_headers); PHP_FUNCTION(litespeed_response_headers); PHP_FUNCTION(apache_get_modules); @@ -1627,17 +1623,6 @@ PHP_FUNCTION(litespeed_finish_request); PHP_MINFO_FUNCTION(litespeed); -static const zend_function_entry litespeed_functions[] = { - PHP_FE(litespeed_request_headers, arginfo_litespeed__void) - PHP_FE(litespeed_response_headers, arginfo_litespeed__void) - PHP_FE(apache_get_modules, arginfo_litespeed__void) - PHP_FE(litespeed_finish_request, arginfo_litespeed__void) - PHP_FALIAS(getallheaders, litespeed_request_headers, arginfo_litespeed__void) - PHP_FALIAS(apache_request_headers, litespeed_request_headers, arginfo_litespeed__void) - PHP_FALIAS(apache_response_headers, litespeed_response_headers, arginfo_litespeed__void) - {NULL, NULL, NULL} -}; - static PHP_MINIT_FUNCTION(litespeed) { user_config_cache_init(); @@ -1675,7 +1660,7 @@ static PHP_MSHUTDOWN_FUNCTION(litespeed) zend_module_entry litespeed_module_entry = { STANDARD_MODULE_HEADER, "litespeed", - litespeed_functions, + ext_functions, PHP_MINIT(litespeed), PHP_MSHUTDOWN(litespeed), NULL, @@ -1697,14 +1682,13 @@ static int add_associate_array( const char * pKey, int keyLen, const char * pVal Fetch all HTTP request headers */ PHP_FUNCTION(litespeed_request_headers) { - /* TODO: */ - if (ZEND_NUM_ARGS() > 0) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters_none() == FAILURE) { + RETURN_THROWS(); } + array_init(return_value); LSAPI_ForeachOrgHeader( add_associate_array, return_value ); - } /* }}} */ @@ -1720,9 +1704,9 @@ PHP_FUNCTION(litespeed_response_headers) int len; char headerBuf[SAPI_LSAPI_MAX_HEADER_LENGTH]; - if (ZEND_NUM_ARGS() > 0) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters_none() == FAILURE) { + RETURN_THROWS(); + } if (!&SG(sapi_headers).headers) { RETURN_FALSE; @@ -1762,10 +1746,11 @@ PHP_FUNCTION(apache_get_modules) "mod_rewrite", "mod_mime", "mod_headers", "mod_expires", "mod_auth_basic", NULL }; const char **name = mod_names; - /* TODO: */ - if (ZEND_NUM_ARGS() > 0) { - WRONG_PARAM_COUNT; - } + + if (zend_parse_parameters_none() == FAILURE) { + RETURN_THROWS(); + } + array_init(return_value); while( *name ) { @@ -1776,13 +1761,13 @@ PHP_FUNCTION(apache_get_modules) /* }}} */ -/* {{{ proto array litespeed_finish_request(void) +/* {{{ proto bool litespeed_finish_request(void) Flushes all response data to the client */ PHP_FUNCTION(litespeed_finish_request) { - if (ZEND_NUM_ARGS() > 0) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters_none() == FAILURE) { + RETURN_THROWS(); + } php_output_end_all(); php_header(); diff --git a/sapi/litespeed/lsapi_main.stub.php b/sapi/litespeed/lsapi_main.stub.php new file mode 100644 index 0000000000..396cb86385 --- /dev/null +++ b/sapi/litespeed/lsapi_main.stub.php @@ -0,0 +1,20 @@ +