From 7162b6918dde9a6a27a2fd9ba756d22694a287a7 Mon Sep 17 00:00:00 2001 From: gggeek Date: Wed, 18 Jan 2023 09:07:12 +0000 Subject: [PATCH] fix handling of unknown methods, recently broken --- src/Server.php | 2 +- tests/5ServerTest.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Server.php b/src/Server.php index 780174de..7b8b4058 100644 --- a/src/Server.php +++ b/src/Server.php @@ -881,7 +881,7 @@ class Server if (!isset($dmap[$methodName]['function'])) { // No such method - throw new PhpXmlrpcException(0, PhpXmlRpc::$xmlrpcstr['unknown_method'], PhpXmlRpc::$xmlrpcerr['unknown_method']); + throw new PhpXmlrpcException(PhpXmlRpc::$xmlrpcstr['unknown_method'], PhpXmlRpc::$xmlrpcerr['unknown_method']); } // alter on-the-fly the config of the xml parser if needed diff --git a/tests/5ServerTest.php b/tests/5ServerTest.php index 829f19ce..ff4c320a 100644 --- a/tests/5ServerTest.php +++ b/tests/5ServerTest.php @@ -360,13 +360,18 @@ class ServerTest extends PhpXmlRpc_PolyfillTestCase new xmlrpcval("\"; exec('ls')", 'int'), )); $v = $this->send($m); - /// @todo a fault condition should be generated here - /// by the server, which we pick up on + /// @todo a specific fault should be generated here by the server, which we can check if ($v) { $this->assertEquals(0, $v->scalarval()); } } + public function testUnknownMethod() + { + $m = new xmlrpcmsg('examples.a_very_unlikely.method', array()); + $v = $this->send($m, \PhpXmlRpc\PhpXmlRpc::$xmlrpcerr['unknown_method']); + } + public function testBoolean() { $m = new xmlrpcmsg('examples.invertBooleans', array( -- 2.47.0