[eluser]gtech[/eluser]
I have logged this as a bug, I am using PHP 5.2.1.. the errors do not seem to be php specific
[url="http://ellislab.com/forums/viewthread/65730/"](thread that shows initial problem)[/url]
Sombody in the post above asked if they could call system.listmethods from the XMLRPC client.. I thought it would be easy to write an example code on how to call it and then discoverd that none of the system methods work.
The XMLRPCS (system/libraries/xmlrpcs.php)code has 4 system functions you can call, one of them being "system.listMethods", "system.methodHelp", "system.methodSignature" and "system.multiCAll".
I have managed to fix the code so the system calls work and I have included the patch below. Some of the errors suggested that this code path hasn't been run before (to be fair its not documented, but the code suggests its designed to support it).
NEW PATCH AND CODE PASTED HERE 28 November 2007, fixes system methods that require parameters!!!!!
example client:
you will need to create a server see the XMLRPC class documentation for an example. you do not need to add the system functions in your server as these are initialised in the xmlrpcs class:
Code:
class myxml extends Controller {
function index()
{
// CLIENT
$this->load->helper('url');
$server_url = site_url('<your xml server controller name>/server');
$this->load->library('xmlrpc');
$this->xmlrpc->server($server_url, 80);
// THIS IS HOW YOU CALL LISTMETHODS
$this->xmlrpc->method('system.listMethods');
$request = array();
// THIS CODE ALSO NOW WORKS ON NEWER PATCH
//$this->xmlrpc->method('system.methodSignature');
//$request = array('system.listMethods');
// THIS CODE ALSO NOW WORKS ON NEWER PATCH
//$this->xmlrpc->method('system.methodHelp');
//$request = array('system.listMethods');
$this->xmlrpc->request($request);
if ( ! $this->xmlrpc->send_request())
{
echo $this->xmlrpc->display_error();
}
else
{
echo '<pre>';
$res = $this->xmlrpc->display_response();
print_r($res);
echo '</pre>';
}
}
}
now the patch created by my subversion repository, note there were missing functions in xmlrpc.php
Code:
Index: Xmlrpc.php
===================================================================
--- Xmlrpc.php (revision 2271)
+++ Xmlrpc.php (working copy)
@@ -1104,6 +1104,7 @@
function addParam($par) { $this->params[]=$par; }
+ function getParam($int) { return $this->params[$int]; }
function output_parameters($array=FALSE)
{
@@ -1384,6 +1385,17 @@
return $b;
}
+ function scalartyp()
+ {
+ global $xmlrpcI4, $xmlrpcInt;
+ reset($this->me);
+ list($a,$b)=each($this->me);
+ if ($a==$xmlrpcI4)
+ {
+ $a=$xmlrpcInt;
+ }
+ return $a;
+ }
//-------------------------------------
// Encode time in ISO-8601 form.
Index: Xmlrpcs.php
===================================================================
--- Xmlrpcs.php (revision 2271)
+++ Xmlrpcs.php (working copy)
@@ -82,7 +82,7 @@
function set_system_methods ()
{
- $system_methods = array(
+ $this->system_methods = array(
'system.listMethods' => array(
'function' => 'this.listMethods',
'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString), array($this->xmlrpcArray)),
@@ -259,7 +259,7 @@
$method_parts = explode(".",$methods[$methName]['function']);
$objectCall = (isset($method_parts['1']) && $method_parts['1'] != "") ? true : false;
- if ($objectCall && !is_callable(array($method_parts['0'],$method_parts['1'])))
+ if ($objectCall && !is_callable(array($method_parts['0'],$method_parts['1'])) && !$sysCall)
{
return new XML_RPC_Response(0,
$this->xmlrpcerr['unknown_method'],
@@ -312,9 +312,9 @@
if ($objectCall)
{
- if ($method_parts['1'] == "this")
+ if ($method_parts['0'] == "this")
{
- return call_user_func(array($this, $method_parts['0']), $m);
+ return call_user_func(array($this, $method_parts['1']), $m);
}
else
{
@@ -340,7 +340,7 @@
{
$v = new XML_RPC_Values();
$output = array();
- foreach($this->$methods as $key => $value)
+ foreach($this->methods as $key => $value)
{
$output[] = new XML_RPC_Values($key, 'string');
}
@@ -407,7 +407,7 @@
$methods = ereg("^system\.", $method_name) ? $this->system_methods : $this->methods;
- if (isset($methods[$methName]))
+ if (isset($methods[$method_name]))
{
$docstring = isset($methods[$method_name]['docstring']) ? $methods[$method_name]['docstring'] : '';
$r = new XML_RPC_Response(new XML_RPC_Values($docstring, 'string'));