fix handling of unknown methods, recently broken
authorgggeek <giunta.gaetano@gmail.com>
Wed, 18 Jan 2023 09:07:12 +0000 (09:07 +0000)
committergggeek <giunta.gaetano@gmail.com>
Wed, 18 Jan 2023 09:07:12 +0000 (09:07 +0000)
src/Server.php
tests/5ServerTest.php

index 780174d..7b8b405 100644 (file)
@@ -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
index 829f19c..ff4c320 100644 (file)
@@ -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(