svn: /pear/packages/XML_RPC2/trunk/ XML/RPC2/Backend/Php/Client.php XML/RPC2/Backend/Xmlrpcext/Client.php XML/RPC2/Client.php
tests/XML_RPC2/regressions/18258.phpt
| From: | Sergio Carvalho | Date: | Thu, 24 Feb 2011 22:08:32 +0000 |
| Subject: | svn: /pear/packages/XML_RPC2/trunk/ XML/RPC2/Backend/Php/Client.php XML/RPC2/Backend/Xmlrpcext/Client.php XML/RPC2/Client.php tests/XML_RPC2/regressions/18258.phpt |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-61255@lists.php.net to get a copy of this message | ||
sergiosgc Thu, 24 Feb 2011 22:08:32 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=308646
Log:
Fix Request #18258 Can not call remote function called create() because XML_RPC2_Client::create()
Bug: http://pear.php.net/bugs/18258 (unknown)
Changed paths:
U pear/packages/XML_RPC2/trunk/XML/RPC2/Backend/Php/Client.php
U pear/packages/XML_RPC2/trunk/XML/RPC2/Backend/Xmlrpcext/Client.php
U pear/packages/XML_RPC2/trunk/XML/RPC2/Client.php
A pear/packages/XML_RPC2/trunk/tests/XML_RPC2/regressions/18258.phpt
Modified: pear/packages/XML_RPC2/trunk/XML/RPC2/Backend/Php/Client.php
===================================================================
--- pear/packages/XML_RPC2/trunk/XML/RPC2/Backend/Php/Client.php 2011-02-24 21:55:40 UTC (rev
308645)
+++ pear/packages/XML_RPC2/trunk/XML/RPC2/Backend/Php/Client.php 2011-02-24 22:08:32 UTC (rev
308646)
@@ -82,21 +82,22 @@
}
// }}}
- // {{{ remoteCall___()
+ // {{{ __call()
/**
- * remoteCall executes the XML-RPC call, and returns the result
+ * __call Catchall. This method catches remote method calls and provides for remote forwarding.
*
- * NB : The '___' at the end of the method name is to avoid collisions with
- * XMLRPC __call()
+ * If the parameters are native types, this method will use XML_RPC_Value::createFromNative to
+ * convert it into an XML-RPC type. Whenever a parameter is already an instance of
XML_RPC_Value
+ * it will be used as provided. It follows that, in situations when
XML_RPC_Value::createFromNative
+ * proves inacurate -- as when encoding DateTime values -- you should present an instance of
+ * XML_RPC_Value in lieu of the native parameter.
*
* @param string Method name
* @param array Parameters
- *
- * @throws XML_RPC2_Exception
- * @throws Exception On failed XML parsing from response
+ * @return mixed The call result, already decoded into native types
*/
- public function remoteCall___($methodName, $parameters)
+ public function __call($methodName, $parameters)
{
$request = new XML_RPC2_Backend_Php_Request($this->prefix . $methodName,
$this->encoding);
$request->setParameters($parameters);
Modified: pear/packages/XML_RPC2/trunk/XML/RPC2/Backend/Xmlrpcext/Client.php
===================================================================
--- pear/packages/XML_RPC2/trunk/XML/RPC2/Backend/Xmlrpcext/Client.php 2011-02-24 21:55:40 UTC (rev
308645)
+++ pear/packages/XML_RPC2/trunk/XML/RPC2/Backend/Xmlrpcext/Client.php 2011-02-24 22:08:32 UTC (rev
308646)
@@ -75,18 +75,22 @@
}
// }}}
- // {{{ remoteCall()
+ // {{{ __call()
/**
- * remoteCall executes the XML-RPC call, and returns the result
+ * __call Catchall. This method catches remote method calls and provides for remote forwarding.
*
- * NB : The '___' at the end of the method name is to avoid collisions with
- * XMLRPC __call()
+ * If the parameters are native types, this method will use XML_RPC_Value::createFromNative to
+ * convert it into an XML-RPC type. Whenever a parameter is already an instance of
XML_RPC_Value
+ * it will be used as provided. It follows that, in situations when
XML_RPC_Value::createFromNative
+ * proves inacurate -- as when encoding DateTime values -- you should present an instance of
+ * XML_RPC_Value in lieu of the native parameter.
*
* @param string Method name
* @param array Parameters
+ * @return mixed The call result, already decoded into native types
*/
- public function remoteCall___($methodName, $parameters)
+ public function __call($methodName, $parameters)
{
$tmp = xmlrpc_encode_request($this->prefix . $methodName, $parameters,
array('escaping' => $this->escaping, 'encoding' =>
$this->encoding));
if ($this->uglyStructHack) {
Modified: pear/packages/XML_RPC2/trunk/XML/RPC2/Client.php
===================================================================
--- pear/packages/XML_RPC2/trunk/XML/RPC2/Client.php 2011-02-24 21:55:40 UTC (rev 308645)
+++ pear/packages/XML_RPC2/trunk/XML/RPC2/Client.php 2011-02-24 22:08:32 UTC (rev 308646)
@@ -138,19 +138,6 @@
protected $uglyStructHack = true;
// }}}
- // {{{ remoteCall___()
- /**
- * remoteCall executes the XML-RPC call, and returns the result
- *
- * NB : The '___' at the end of the method name is to avoid collisions with
- * XMLRPC __call()
- *
- * @param string Method name
- * @param array Parameters
- */
- public abstract function remoteCall___($methodName, $parameters);
-
- // }}}
// {{{ constructor
/**
@@ -227,6 +214,9 @@
*/
public static function create($uri, $options = array())
{
+ if (isset($this)) { // Method called non-statically forward to remote call() as RPC
+ $this->__call('create', func_get_args());
+ }
if (isset($options['backend'])) {
XML_RPC2_Backend::setBackend($options['backend']);
}
@@ -250,11 +240,7 @@
* @param array Parameters
* @return mixed The call result, already decoded into native types
*/
- public function __call($methodName, $parameters)
- {
- $args = array($methodName, $parameters);
- return @call_user_func_array(array($this, 'remoteCall___'), $args);
- }
+ public abstract function __call($methodName, $parameters);
// }}}
}
Added: pear/packages/XML_RPC2/trunk/tests/XML_RPC2/regressions/18258.phpt
===================================================================
--- pear/packages/XML_RPC2/trunk/tests/XML_RPC2/regressions/18258.phpt (rev
0)
+++ pear/packages/XML_RPC2/trunk/tests/XML_RPC2/regressions/18258.phpt 2011-02-24 22:08:32 UTC (rev
308646)
@@ -0,0 +1,48 @@
+--TEST--
+Request #18258 Can not call remote function called create() because XML_RPC2_Client::create()
+--FILE--
+<?php
+set_include_path(realpath(dirname(__FILE__) . '/../../../') . PATH_SEPARATOR .
get_include_path());
+require_once 'XML/RPC2/Server.php';
+require_once 'XML/RPC2/Client.php';
+require_once 'XML/RPC2/Backend/Php/Request.php';
+
+
+class TestServer {
+
+ /**
+ * returns something
+ *
+ * @param int $id Some id
+ *
+ * @return id The same id
+ */
+ public static function create($id)
+ {
+ return $id;
+ }
+
+}
+
+$options = array(
+ 'prefix' => 'test.',
+ 'encoding' => 'utf-8'
+);
+
+$server = XML_RPC2_Server::create('TestServer', $options);
+$request = new XML_RPC2_Backend_Php_Request('test.create');
+$request->addParameter(12);
+$GLOBALS['HTTP_RAW_POST_DATA'] = $request->encode();
+$server->handleCall();
+?>
+--EXPECT--
+<?xml version="1.0" encoding="utf-8"?>
+<methodResponse>
+<params>
+ <param>
+ <value>
+ <int>12</int>
+ </value>
+ </param>
+</params>
+</methodResponse>