From: gggeek Date: Sun, 12 Apr 2015 12:48:05 +0000 (+0100) Subject: Consistent with server, at debug level 1, request will not dump the rebuilt php objec... X-Git-Tag: 4.0.0-alpha^2~90 X-Git-Url: http://git.onelab.eu/?p=plcapi.git;a=commitdiff_plain;h=a3b1d45eb2e1fd0712d574a423c6c4af8d512ee1 Consistent with server, at debug level 1, request will not dump the rebuilt php object to screen; let paring tests echo the xml they use, as http tests do --- diff --git a/NEWS b/NEWS index 9f0bd69..b2c5fb3 100644 --- a/NEWS +++ b/NEWS @@ -49,6 +49,8 @@ PLEASE READ CAREFULLY THE NOTES BELOW to insure a smooth upgrade. * improved: echo all debug messages even when there are characters in them which php deems in a wrong encoding (this is visible e.g. in the debugger) +* improved: at debug level 1, the rebuilt php objects are not dumped to screen (server-side already did that) + XML-RPC for PHP version 3.0.0 - 2014/6/15 diff --git a/src/Client.php b/src/Client.php index 79948e8..d3f7540 100644 --- a/src/Client.php +++ b/src/Client.php @@ -363,7 +363,7 @@ class Client } // where req is a Request - $req->debug = $this->debug; + $req->setDebug($this->debug); if ($method == 'https') { $r = $this->sendPayloadHTTPS( diff --git a/src/Request.php b/src/Request.php index 8b367f1..7d5a8a0 100644 --- a/src/Request.php +++ b/src/Request.php @@ -317,7 +317,7 @@ class Request $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'], PhpXmlRpc::$xmlrpcstr['invalid_return']); } else { - if ($this->debug) { + if ($this->debug > 1) { Logger::instance()->debugMessage( "---PARSED---\n".var_export($xmlRpcParser->_xh['value'], true)."\n---END---" ); @@ -355,4 +355,14 @@ class Request return $r; } + + /** + * Enables/disables the echoing to screen of the xmlrpc responses received. + * + * @param integer $in values 0, 1, 2 are supported + */ + public function setDebug($in) + { + $this->debug = $in; + } } diff --git a/tests/1ParsingBugsTest.php b/tests/1ParsingBugsTest.php index e4a3048..4bbccba 100644 --- a/tests/1ParsingBugsTest.php +++ b/tests/1ParsingBugsTest.php @@ -7,6 +7,22 @@ include_once __DIR__ . '/../lib/xmlrpcs.inc'; class ParsingBugsTests extends PHPUnit_Framework_TestCase { + public $args = array(); + + public function setUp() + { + $this->args = argParser::getArgs(); + } + + protected function newMsg($methodName, $params = array()) + { + $msg = new xmlrpcmsg($methodName, $params); + if ($this->args['DEBUG']) { + $msg->setDebug($this->args['DEBUG']); + } + return $msg; + } + public function testMinusOneString() { $v = new xmlrpcval('-1'); @@ -32,7 +48,7 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase $v = array($str => new xmlrpcval(1)); $r = new xmlrpcresp(new xmlrpcval($v, 'struct')); $r = $r->serialize(); - $m = new xmlrpcmsg('dummy'); + $m = $this->newMsg('dummy'); $r = $m->parseResponse($r); $v = $r->value(); $this->assertEquals($v->structmemexists($str), true); @@ -62,7 +78,7 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase '); - $m = new xmlrpcmsg('dummy'); + $m = $this->newMsg('dummy'); $r = $m->parseResponse($response); $v = $r->faultString(); $this->assertEquals(chr(224) . chr(252) . chr(232) . chr(224) . chr(252) . chr(232), $v); @@ -70,7 +86,7 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase public function testValidNumbers() { - $m = new xmlrpcmsg('dummy'); + $m = $this->newMsg('dummy'); $fp = ' @@ -193,8 +209,7 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase public function testBrokenResponses() { - $m = new xmlrpcmsg('dummy'); - //$m->debug = 1; + $m = $this->newMsg('dummy'); // omitting the 'params' tag: no more tolerated by the lib... $f = ' @@ -226,7 +241,7 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase public function testBuggyHttp() { - $s = new xmlrpcmsg('dummy'); + $s = $this->newMsg('dummy'); $f = 'HTTP/1.1 100 Welcome to the jungle HTTP/1.0 200 OK @@ -253,7 +268,7 @@ and there they were.postid7414222newMsg('dummy'); $f = '