summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-08-14 03:15:01 +0000
committerDries Buytaert <dries@buytaert.net>2010-08-14 03:15:01 +0000
commit0a481a7899ee903994a2c9cf3c8cc7bc9b9bf5f6 (patch)
tree547038f8c47beada9840f0bfcde809349cc9eff1 /includes
parent8f7eae302e5653b752e25d95ba1b5ba597727134 (diff)
downloadbrdo-0a481a7899ee903994a2c9cf3c8cc7bc9b9bf5f6.tar.gz
brdo-0a481a7899ee903994a2c9cf3c8cc7bc9b9bf5f6.tar.bz2
- Patch #881536 by sun, pwolanin: cannot pass drupal_http_request() options into xmlrpc() function.
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc27
-rw-r--r--includes/xmlrpc.inc40
2 files changed, 35 insertions, 32 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 2a14c2c26..412c8df04 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -6747,16 +6747,22 @@ function entity_form_submit_build_entity($entity_type, $entity, $form, &$form_st
/**
* Performs one or more XML-RPC request(s).
*
+ * Usage example:
+ * @code
+ * $result = xmlrpc('http://example.com/xmlrpc.php', array(
+ * 'service.methodName' => array($parameter, $second, $third),
+ * ));
+ * @endcode
+ *
* @param $url
* An absolute URL of the XML-RPC endpoint.
- * Example:
- * http://www.example.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.
+ * @param $args
+ * An associative array whose keys are the methods to call and whose values
+ * are the arguments to pass to the respective method. If multiple methods
+ * are specified, a system.multicall is performed.
+ * @param $options
+ * (optional) An array of options to pass along to drupal_http_request().
+ *
* @return
* For one request:
* Either the return value of the method on success, or FALSE.
@@ -6766,10 +6772,9 @@ function entity_form_submit_build_entity($entity_type, $entity, $form, &$form_st
* returned by the method called, or an xmlrpc_error object if the call
* failed. See xmlrpc_error().
*/
-function xmlrpc($url) {
+function xmlrpc($url, $args, $options = array()) {
require_once DRUPAL_ROOT . '/includes/xmlrpc.inc';
- $args = func_get_args();
- return call_user_func_array('_xmlrpc', $args);
+ return _xmlrpc($url, $args, $options);
}
/**
diff --git a/includes/xmlrpc.inc b/includes/xmlrpc.inc
index 30dee3ac5..40b0d9d03 100644
--- a/includes/xmlrpc.inc
+++ b/includes/xmlrpc.inc
@@ -528,14 +528,14 @@ function xmlrpc_base64_get_xml($xmlrpc_base64) {
* Performs one or more XML-RPC requests.
*
* @param $url
- * The absolute URL of the XML-RPC endpoint. Example:
- * http://www.example.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.
+ * An absolute URL of the XML-RPC endpoint, e.g.,
+ * http://example.com/xmlrpc.php
+ * @param $args
+ * An associative array whose keys are the methods to call and whose values
+ * are the arguments to pass to the respective method. If multiple methods
+ * are specified, a system.multicall is performed.
+ * @param $options
+ * (optional) An array of options to pass along to drupal_http_request().
*
* @return
* A single response (single request) or an array of responses (multicall
@@ -544,27 +544,25 @@ function xmlrpc_base64_get_xml($xmlrpc_base64) {
* is returned, see xmlrpc_errno() and xmlrpc_error_msg() to get more
* information.
*/
-function _xmlrpc() {
- $args = func_get_args();
- $url = array_shift($args);
+function _xmlrpc($url, $args, $options = array()) {
xmlrpc_clear_error();
- if (is_array($args[0])) {
- $method = 'system.multicall';
+ if (count($args) > 1) {
$multicall_args = array();
- foreach ($args[0] as $call) {
- $multicall_args[] = array('methodName' => array_shift($call), 'params' => $call);
+ foreach ($args as $method => $call) {
+ $multicall_args[] = array('methodName' => $method, 'params' => $call);
}
+ $method = 'system.multicall';
$args = array($multicall_args);
}
else {
- $method = array_shift($args);
+ $method = key($args);
+ $args = $args[$method];
}
$xmlrpc_request = xmlrpc_request($method, $args);
- $options = array(
- 'headers' => array('Content-Type' => 'text/xml'),
- 'method' => 'POST',
- 'data' => $xmlrpc_request->xml,
- );
+ // Required options which will replace any that are passed in.
+ $options['method'] = 'POST';
+ $options['headers']['Content-Type'] = 'text/xml';
+ $options['data'] = $xmlrpc_request->xml;
$result = drupal_http_request($url, $options);
if ($result->code != 200) {
xmlrpc_error($result->code, $result->error);