Skip to content

Commit e8d99c6

Browse files
committed
add a Wrapper method to help the json-rpc debugger to generate 1.0/2.0 code
1 parent b73d50c commit e8d99c6

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

NEWS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* improved: allow to force usage of HTTP 1.1. when using curl for calls, via usage of 'http11_only'
44

55
* improved: added new methods: `Server::generatePayload($resp, $respCharset)`,
6-
`Server::printPayload($payload, $resp->getContentType(), $respEncoding)` and `HTTP::setAcceptedStatusCodes($statusCodes)`
7-
to help subclasses such as the Json-Rpc server and request
6+
`Server::printPayload($payload, $resp->getContentType(), $respEncoding)` , `HTTP::setAcceptedStatusCodes($statusCodes)`
7+
and `Wrapper::cloneClientForClosure($client)` to help subclasses such as the Json-Rpc server and request
88

99
* improved: prepare the debugger for json-rpc 2.0 support, which will be in a pending release of the PhpJsonRpc library
1010

debugger/action.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,9 @@
585585
}
586586
if ($wstype == 1 || $wstype == 2) {
587587
$wrapper = new PhpXmlRpc\JsonRpc\Wrapper();
588+
if ($hasjsonrpc2) {
589+
$wrapper->setJsonRpcVersion($wstype == 1 ? \PhpXmlRpc\JsonRpc\PhpJsonRpc::VERSION_1_0 : \PhpXmlRpc\JsonRpc\PhpJsonRpc::VERSION_2_0);
590+
}
588591
} else {
589592
$wrapper = new PhpXmlRpc\Wrapper();
590593
}

src/Wrapper.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ protected function generateMethodNameForClassMethod($className, $classMethod, $e
740740
* trusted servers ---
741741
* - mixed return_on_fault a php value to be returned when the xml-rpc call fails/returns
742742
* a fault response (by default the Response object is returned
743-
* in this case). If a string is used, '%faultCode%' and
743+
* in this case). If a string is used, '%faultCode%' and
744744
* '%faultString%' tokens will be substituted with actual error values
745745
* - bool throw_on_fault if true, throw an exception instead of returning a Response
746746
* in case of errors/faults;
@@ -877,7 +877,7 @@ protected function retrieveMethodHelp($client, $methodName, array $extraOptions
877877
protected function buildWrapMethodClosure($client, $methodName, array $extraOptions, $mSig)
878878
{
879879
// we clone the client, so that we can modify it a bit independently of the original
880-
$clientClone = clone $client;
880+
$clientClone = $this->cloneClientForClosure($client);
881881
$function = function() use($clientClone, $methodName, $extraOptions, $mSig)
882882
{
883883
$timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0;
@@ -1270,4 +1270,13 @@ public static function getHeldObject($index)
12701270

12711271
throw new ValueErrorException("No object held for index '$index'");
12721272
}
1273+
1274+
/**
1275+
* @param Client $client
1276+
* @return Client
1277+
*/
1278+
protected function cloneClientForClosure($client)
1279+
{
1280+
return clone $client;
1281+
}
12731282
}

0 commit comments

Comments
 (0)