Commit d6bcdafe authored by Dries's avatar Dries

- Patch #7458 by chx: merged the XML-RPC multicall support into xmlrpc() and...

- Patch #7458 by chx: merged the XML-RPC multicall support into xmlrpc() and use lazy-loading for the XML-RPC libraries.(performance improvement).
parent 05014a31
......@@ -1826,6 +1826,34 @@ function drupal_implode_autocomplete($array) {
return implode('||', $output);
}
/**
* Performs one or more XML-RPC request(s).
*
* @param $url
* An absolute URL of the XML-RPC endpoint.
* Example:
* http://www.domain.com/xmlrpc.php
* @param ...
* For one request:
* The method name followed by a variable number of arguments to the method.
* For multiple requests (system.multicall):
* An array of call arrays. Each call array follows the pattern of the single
* request: method name followed by the arguments to the method.
* @return
* For one request:
* Either the return value of the method on success, or FALSE.
* If FALSE is returned, see xmlrpc_errno() and xmlrpc_error_msg().
* For multiple requests:
* An array of results. Each result will either be the result
* returned by the method called, or an xmlrpc_error object if the call
* failed. See xmlrpc_error().
*/
function xmlrpc($url) {
require_once './includes/xmlrpc.inc';
$args = func_get_args();
return call_user_func_array('_xmlrpc', $args);
}
function _drupal_bootstrap_full() {
static $called;
global $locale;
......@@ -1840,7 +1868,6 @@ function _drupal_bootstrap_full() {
require_once './includes/tablesort.inc';
require_once './includes/file.inc';
require_once './includes/unicode.inc';
require_once './includes/xmlrpc.inc';
require_once './includes/image.inc';
// Set the Drupal custom error handler.
set_error_handler('error_handler');
......
......@@ -340,25 +340,21 @@ function xmlrpc_base64_get_xml($xmlrpc_base64) {
return '<base64>'. base64_encode($xmlrpc_base64->data) .'</base64>';
}
/**
* 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
*/
......
......@@ -6,9 +6,10 @@
* PHP page for handling incoming XML-RPC requests from clients.
*/
include_once 'includes/bootstrap.inc';
include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
include_once 'includes/xmlrpcs.inc';
include_once './includes/xmlrpc.inc';
include_once './includes/xmlrpcs.inc';
xmlrpc_server(module_invoke_all('xmlrpc'));
?>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment