X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fxmlrpc_wrappers.inc;h=cec33742a9d60caf88c1e84b903af16dc720e6d8;hb=1c13905fd4fc8b5177aab001489e6f6bf557389a;hp=021b1ce133ee27963fa520da465a4cafd771d019;hpb=ca1ecacd1a0c24c1b16aa7ecbd39ea3bb01e338b;p=plcapi.git diff --git a/lib/xmlrpc_wrappers.inc b/lib/xmlrpc_wrappers.inc index 021b1ce..cec3374 100644 --- a/lib/xmlrpc_wrappers.inc +++ b/lib/xmlrpc_wrappers.inc @@ -34,7 +34,6 @@ function xmlrpc_2_php_type($xmlrpcType) return $wrapper->xmlrpc2PhpType($xmlrpcType); } -/// @todo backwards compat: return string instead of callable /** * @see PhpXmlRpc\Wrapper::wrap_php_function * @param callable $funcName @@ -45,11 +44,21 @@ function xmlrpc_2_php_type($xmlrpcType) function wrap_php_function($funcName, $newFuncName='', $extraOptions=array()) { $wrapper = new PhpXmlRpc\Wrapper(); - return $wrapper->wrapPhpFunction($funcName, $newFuncName, $extraOptions); + if (!isset($extraOptions['return_source']) || $extraOptions['return_source'] == false) { + // backwards compat: return string instead of callable + $extraOptions['return_source'] = true; + $wrapped = $wrapper->wrapPhpFunction($funcName, $newFuncName, $extraOptions); + eval($wrapped['source']); + } else { + $wrapped = $wrapper->wrapPhpFunction($funcName, $newFuncName, $extraOptions); + } + return $wrapped; } -/// @todo backwards compat: return strings instead of callables /** + * NB: this function returns an array in a format which is unsuitable for direct use in the server dispatch map, unlike + * PhpXmlRpc\Wrapper::wrapPhpClass. This behaviour might seem like a bug, but has been kept for backwards compatibility. + * * @see PhpXmlRpc\Wrapper::wrap_php_class * @param string|object $className * @param array $extraOptions @@ -58,10 +67,22 @@ function wrap_php_function($funcName, $newFuncName='', $extraOptions=array()) function wrap_php_class($className, $extraOptions=array()) { $wrapper = new PhpXmlRpc\Wrapper(); - return $wrapper->wrapPhpClass($className, $extraOptions); + $fix = false; + if (!isset($extraOptions['return_source']) || $extraOptions['return_source'] == false) { + // backwards compat: return string instead of callable + $extraOptions['return_source'] = true; + $fix = true; + } + $wrapped = $wrapper->wrapPhpClass($className, $extraOptions); + foreach($wrapped as $name => $value) { + if ($fix) { + eval($value['source']); + } + $wrapped[$name] = $value['function']; + } + return $wrapped; } -/// @todo backwards compat: return string instead of callable /** * @see PhpXmlRpc\Wrapper::wrapXmlrpcMethod * @param xmlrpc_client $client @@ -86,10 +107,19 @@ function wrap_xmlrpc_method($client, $methodName, $extraOptions=0, $timeout=0, $ } $wrapper = new PhpXmlRpc\Wrapper(); - return $wrapper->wrapXmlrpcMethod($client, $methodName, $extraOptions); + + if (!isset($extraOptions['return_source']) || $extraOptions['return_source'] == false) { + // backwards compat: return string instead of callable + $extraOptions['return_source'] = true; + $wrapped = $wrapper->wrapXmlrpcMethod($client, $methodName, $extraOptions); + eval($wrapped['source']); + $wrapped = $wrapped['function']; + } else { + $wrapped = $wrapper->wrapXmlrpcMethod($client, $methodName, $extraOptions); + } + return $wrapped; } -/// @todo backwards compat: return strings instead of callables /** * @see PhpXmlRpc\Wrapper::wrap_xmlrpc_server * @param xmlrpc_client $client @@ -102,7 +132,6 @@ function wrap_xmlrpc_server($client, $extraOptions=array()) return $wrapper->wrapXmlrpcServer($client, $extraOptions); } -/// @todo fix dangling usage of $this-> /** * Given the necessary info, build php code that creates a new function to invoke a remote xmlrpc method. * Take care that no full checking of input parameters is done to ensure that valid php code is emitted. @@ -143,7 +172,7 @@ function build_remote_method_wrapper_code($client, $methodName, $xmlrpcFuncName, for ($i = 1; $i < $pCount; $i++) { $plist[] = "\$p$i"; $pType = $mSig[$i]; - if ($pType == 'i4' || $pType == 'int' || $pType == 'boolean' || $pType == 'double' || + if ($pType == 'i4' || $pType == 'i8' || $pType == 'int' || $pType == 'boolean' || $pType == 'double' || $pType == 'string' || $pType == 'dateTime.iso8601' || $pType == 'base64' || $pType == 'null' ) { // only build directly xmlrpc values when type is known and scalar @@ -211,4 +240,4 @@ function build_client_wrapper_code($client, $verbatim_client_copy, $prefix='xmlr $code .= "\$client->return_type = '{$prefix}vals';\n"; //$code .= "\$client->setDebug(\$debug);\n"; return $code; -} \ No newline at end of file +}