summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2005-08-17 15:01:14 +0000
committerDries Buytaert <dries@buytaert.net>2005-08-17 15:01:14 +0000
commitd6bcdafeedeb97e4c08586c518b0f27cb3a022db (patch)
tree00ea09233b432ce75b1fa6c66ca2c55bf87df05a
parent05014a31353af85cb549a87c03604114eac9b13c (diff)
downloadbrdo-d6bcdafeedeb97e4c08586c518b0f27cb3a022db.tar.gz
brdo-d6bcdafeedeb97e4c08586c518b0f27cb3a022db.tar.bz2
- Patch #7458 by chx: merged the XML-RPC multicall support into xmlrpc() and use lazy-loading for the XML-RPC libraries.(performance improvement).
-rw-r--r--includes/common.inc29
-rw-r--r--includes/xmlrpc.inc52
-rw-r--r--xmlrpc.php5
3 files changed, 43 insertions, 43 deletions
diff --git a/includes/common.inc b/includes/common.inc
index c9b61d402..993e0354a 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -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');
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>'. 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);
@@ -381,30 +377,6 @@ function xmlrpc() {
}
/**
- * 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
*/
function xmlrpc_errno() {
diff --git a/xmlrpc.php b/xmlrpc.php
index 3cfc87493..7db4acfb3 100644
--- a/xmlrpc.php
+++ b/xmlrpc.php
@@ -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'));
?>