From d6bcdafeedeb97e4c08586c518b0f27cb3a022db Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 17 Aug 2005 15:01:14 +0000 Subject: - Patch #7458 by chx: merged the XML-RPC multicall support into xmlrpc() and use lazy-loading for the XML-RPC libraries.(performance improvement). --- includes/xmlrpc.inc | 52 ++++++++++++---------------------------------------- 1 file changed, 12 insertions(+), 40 deletions(-) (limited to 'includes/xmlrpc.inc') diff --git a/includes/xmlrpc.inc b/includes/xmlrpc.inc index 655fe996d..0f183bcf8 100644 --- a/includes/xmlrpc.inc +++ b/includes/xmlrpc.inc @@ -340,25 +340,21 @@ function xmlrpc_base64_get_xml($xmlrpc_base64) { return ''. base64_encode($xmlrpc_base64->data) .''; } -/** - * Perform an XML-RPC request. - * - * @param $url - * An absolute URL of the XML-RPC server - * @param $method - * The method to be executed - * @param ... - * A variable number of arguments of the method. - * @return - * The return value of the method on success or FALSE. On FALSE, see - * xmlrpc_errno() and xmlrpc_error_msg(). - */ -function xmlrpc() { +function _xmlrpc() { $args = func_get_args(); $url = array_shift($args); - $method = array_shift($args); + if (is_array($args[0])) { + $method = 'system.multicall'; + $multicall_args = array(); + foreach ($args[0] as $call) { + $multicall_args[] = array('methodName' => array_shift($call),'params' => $call); + } + $args = array($multicall_args); + } + else { + $method = array_shift($args); + } $xmlrpc_request = xmlrpc_request($method, $args); -// $request .= "Content-Type: text/xml$r"; $result = drupal_http_request($url, array("Content-Type" => "text/xml"), 'POST', $xmlrpc_request->xml); if ($result->code != 200) { xmlrpc_error(-$result->code, $result->error); @@ -380,30 +376,6 @@ function xmlrpc() { return $message->params[0]; } -/** - * Perform multiple calls in one request if possible. - * - * @param $url - * An absolute URL of the XML-RPC server - * @param $calls - * An array of calls. Each call is an array, where the first element - * is the method name, further elements are the arguments. - * @return - * An array of results. - */ -function xmlrpc_multicall() { - $args = func_get_args(); - $url = $args[0]; - foreach ($args[1] as $call) { - $method = array_shift($call); - $calls[] = array( - 'methodName' => $method, - 'params' => $call - ); - } - return xmlrpc($url, 'system.multicall', $calls); -} - /** * Returns the last XML-RPC client error number */ -- cgit v1.2.3