Browse Source

[[ZF-5635]] Fatal error when calling Zend_XmlRpc_Server_System system.multicall method

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@17775 44c647ce-9c0f-0410-b52a-842ac1e357ba
lars 16 years ago
parent
commit
868c650ed7
2 changed files with 35 additions and 1 deletions
  1. 5 1
      library/Zend/XmlRpc/Server/System.php
  2. 30 0
      tests/Zend/XmlRpc/ServerTest.php

+ 5 - 1
library/Zend/XmlRpc/Server/System.php

@@ -137,7 +137,11 @@ class Zend_XmlRpc_Server_System
                     $request->setMethod($method['methodName']);
                     $request->setParams($method['params']);
                     $response = $this->_server->handle($request);
-                    $responses[] = $response->getReturnValue();
+                    if ($response->isFault()) {
+                        $falt = $response;
+                    } else {
+                        $responses[] = $response->getReturnValue();
+                    }
                 } catch (Exception $e) {
                     $fault = $this->_server->fault($e);
                 }

+ 30 - 0
tests/Zend/XmlRpc/ServerTest.php

@@ -381,6 +381,36 @@ class Zend_XmlRpc_ServerTest extends PHPUnit_Framework_TestCase
     }
 
     /**
+     * @group ZF-5635
+     */
+    public function testMulticallHandlesFaults()
+    {
+        $struct = array(
+            array(
+                'methodName' => 'system.listMethods',
+                'params' => array()
+            ),
+            array(
+                'methodName' => 'undefined',
+                'params' => array()
+            )
+        );
+        $request = new Zend_XmlRpc_Request();
+        $request->setMethod('system.multicall');
+        $request->addParam($struct);
+        $response = $this->_server->handle($request);
+
+        $this->assertTrue($response instanceof Zend_XmlRpc_Response, $response->__toString() . "\n\n" . $request->__toString());
+        $returns = $response->getReturnValue();
+        $this->assertTrue(is_array($returns));
+        $this->assertEquals(2, count($returns), var_export($returns, 1));
+        $this->assertTrue(is_array($returns[0]), var_export($returns[0], 1));
+        $this->assertSame(array(
+            'faultCode' => 404, 'faultString' => 'Unknown error'),
+            $returns[1], var_export($returns[1], 1));
+    }
+
+    /**
      * Test get/setEncoding()
      */
     public function testGetSetEncoding()