From: Stanislav Malyshev Date: Tue, 18 Aug 2009 00:41:43 +0000 (+0000) Subject: cleanup parameter parsing X-Git-Tag: php-5.4.0alpha1~191^2~2786 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ae69e05ad339de05b4aac294a6ebe198133ea564;p=php cleanup parameter parsing --- diff --git a/ext/xmlrpc/tests/001.phpt b/ext/xmlrpc/tests/001.phpt index 99fd958d29..2625096714 100644 --- a/ext/xmlrpc/tests/001.phpt +++ b/ext/xmlrpc/tests/001.phpt @@ -38,19 +38,8 @@ string(160) " " -Notice: Array to string conversion in %s on line %d -string(177) " - -Array - - - - 1 - - - - -" +Warning: xmlrpc_encode_request() expects parameter 1 to be string, array given in %s on line %d +NULL string(175) " 3.4 diff --git a/ext/xmlrpc/tests/002.phpt b/ext/xmlrpc/tests/002.phpt index c8d722b808..83586464bc 100644 --- a/ext/xmlrpc/tests/002.phpt +++ b/ext/xmlrpc/tests/002.phpt @@ -47,10 +47,7 @@ array(1) { } string(2) "-1" -Notice: Array to string conversion in %s on line %d -array(1) { - [0]=> - int(1) -} -string(5) "Array" +Warning: xmlrpc_encode_request() expects parameter 1 to be string, array given in %s on line %d +NULL +string(2) "-1" Done diff --git a/ext/xmlrpc/tests/bug42189.phpt b/ext/xmlrpc/tests/bug42189.phpt index 2b4e47ade7..55e726cf68 100644 --- a/ext/xmlrpc/tests/bug42189.phpt +++ b/ext/xmlrpc/tests/bug42189.phpt @@ -11,5 +11,5 @@ var_dump($ok); echo "Done\n"; ?> --EXPECT-- -bool(true) +bool(false) Done diff --git a/ext/xmlrpc/xmlrpc-epi-php.c b/ext/xmlrpc/xmlrpc-epi-php.c index 0bbf138b97..4234cc5d4b 100644 --- a/ext/xmlrpc/xmlrpc-epi-php.c +++ b/ext/xmlrpc/xmlrpc-epi-php.c @@ -688,10 +688,12 @@ PHP_FUNCTION(xmlrpc_encode_request) { XMLRPC_REQUEST xRequest = NULL; char *outBuf; - zval **method, **vals, *out_opts = NULL; + zval *vals, *out_opts = NULL; + char *method = NULL; + int method_len; php_output_options out; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ|a", &method, &vals, &out_opts) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!z|a", &method, &method_len, &vals, &out_opts) == FAILURE) { return; } @@ -702,15 +704,14 @@ PHP_FUNCTION(xmlrpc_encode_request) if (xRequest) { XMLRPC_RequestSetOutputOptions(xRequest, &out.xmlrpc_out); - if (Z_TYPE_PP(method) == IS_NULL) { + if (method == NULL) { XMLRPC_RequestSetRequestType(xRequest, xmlrpc_request_response); } else { - convert_to_string_ex(method); - XMLRPC_RequestSetMethodName(xRequest, Z_STRVAL_PP(method)); + XMLRPC_RequestSetMethodName(xRequest, method); XMLRPC_RequestSetRequestType(xRequest, xmlrpc_request_call); } - if (Z_TYPE_PP(vals) != IS_NULL) { - XMLRPC_RequestSetData(xRequest, PHP_to_XMLRPC(*vals TSRMLS_CC)); + if (Z_TYPE_P(vals) != IS_NULL) { + XMLRPC_RequestSetData(xRequest, PHP_to_XMLRPC(vals TSRMLS_CC)); } outBuf = XMLRPC_REQUEST_ToXML(xRequest, 0); @@ -800,7 +801,6 @@ PHP_FUNCTION(xmlrpc_decode_request) return; } - convert_to_string_ex(method); if (return_value_used) { zval* retval = decode_request_worker(xml, xml_len, encoding_len ? encoding : NULL, *method); @@ -1061,20 +1061,20 @@ PHP_FUNCTION(xmlrpc_server_call_method) XMLRPC_REQUEST xRequest; STRUCT_XMLRPC_REQUEST_INPUT_OPTIONS input_opts; xmlrpc_server_data* server; - zval **caller_params, *handle, **output_opts = NULL; + zval **caller_params, *handle, *output_opts = NULL; char *rawxml; int rawxml_len, type; php_output_options out; int argc =ZEND_NUM_ARGS(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsZ|Z", &handle, &rawxml, &rawxml_len, &caller_params, &output_opts) != SUCCESS) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsZ|a", &handle, &rawxml, &rawxml_len, &caller_params, &output_opts) != SUCCESS) { return; } /* user output options */ if (argc == 3) { set_output_options(&out, NULL); } else { - set_output_options(&out, *output_opts); + set_output_options(&out, output_opts); } server = zend_list_find(Z_LVAL_P(handle), &type);