/******************************************************************************
*
- *** DEPRECATED ***
+ * *** DEPRECATED ***
*
* This file is only used to insure backwards compatibility
* with the API of the library <= rev. 3
return $wrapper->xmlrpc2PhpType($xmlrpcType);
}
-/// @todo backwards compat: return string instead of callable
/**
* @see PhpXmlRpc\Wrapper::wrap_php_function
* @param callable $funcName
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
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
* @param string $methodName
- * @param int|array $extraOptions the usage of an int as signature number is deprecated, use an option in $extraOptions
+ * @param int|array $extraOptions the usage of an int as signature number is deprecated, use an option 'signum' in $extraOptions
* @param int $timeout deprecated, use an option in $extraOptions
* @param string $protocol deprecated, use an option in $extraOptions
* @param string $newFuncName deprecated, use an option in $extraOptions
}
$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);
+ if (is_array($wrapped)) {
+ 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
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.
$code = "function $xmlrpcFuncName (";
if ($clientCopyMode < 2) {
// client copy mode 0 or 1 == partial / full client copy in emitted code
- $innerCode = $this->build_client_wrapper_code($client, $clientCopyMode, $prefix, $namespace);
+ $innerCode = build_client_wrapper_code($client, $clientCopyMode, $prefix, $namespace);
$innerCode .= "\$client->setDebug(\$debug);\n";
$this_ = '';
} else {
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
return array('source' => $code, 'docstring' => $mDesc);
}
+
+/**
+ * @deprecated
+ */
+function build_client_wrapper_code($client, $verbatim_client_copy, $prefix='xmlrpc')
+{
+ $code = "\$client = new {$prefix}_client('".str_replace("'", "\'", $client->path).
+ "', '" . str_replace("'", "\'", $client->server) . "', $client->port);\n";
+
+ // copy all client fields to the client that will be generated runtime
+ // (this provides for future expansion or subclassing of client obj)
+ if ($verbatim_client_copy)
+ {
+ foreach($client as $fld => $val)
+ {
+ if($fld != 'debug' && $fld != 'return_type')
+ {
+ $val = var_export($val, true);
+ $code .= "\$client->$fld = $val;\n";
+ }
+ }
+ }
+ // only make sure that client always returns the correct data type
+ $code .= "\$client->return_type = '{$prefix}vals';\n";
+ //$code .= "\$client->setDebug(\$debug);\n";
+ return $code;
+}