From 638f751a07b8dae927ca7d6825134bcde5c1098a Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Wed, 9 Dec 2015 02:58:12 -0600 Subject: [PATCH] MDL-52209 webservice_xmlrpc: Remove Zend from webservice_xmlrpc Additional fixes. --- webservice/upgrade.txt | 7 +++++++ webservice/xmlrpc/lib.php | 2 +- webservice/xmlrpc/locallib.php | 6 ++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/webservice/upgrade.txt b/webservice/upgrade.txt index 0deb3b20a3aa7..9fc805946d031 100644 --- a/webservice/upgrade.txt +++ b/webservice/upgrade.txt @@ -3,6 +3,13 @@ information provided here is intended especially for developers. This information is intended for authors of webservices, not people writing webservice clients. +=== 3.1 === + +* Zend_XmlRpc has been dropped from webservice_xmlrpc. Fault strings that were generated by + Zend_XmlRpc_XXX_Exception exceptions (i.e. 'Method "[methodname]" does not exist') are no longer used + which may display a different error message depending on the string returned by the getMessage() + method of the thrown exception. + === 3.0 === * WS protocols webservice/myprotocol:use capabilities were defined with a high riskbitmask value diff --git a/webservice/xmlrpc/lib.php b/webservice/xmlrpc/lib.php index 6cb9cf718b0d5..2a46887725467 100644 --- a/webservice/xmlrpc/lib.php +++ b/webservice/xmlrpc/lib.php @@ -95,7 +95,7 @@ public function call($functionname, $params = array()) { // Decode the response. $result = xmlrpc_decode($response); if (is_array($result) && xmlrpc_is_fault($result)) { - throw new moodle_exception($result['faultString']); + throw new Exception($result['faultString'], $result['faultCode']); } return $result; diff --git a/webservice/xmlrpc/locallib.php b/webservice/xmlrpc/locallib.php index c97ed7d398b26..9803b9d530566 100644 --- a/webservice/xmlrpc/locallib.php +++ b/webservice/xmlrpc/locallib.php @@ -103,7 +103,8 @@ protected function prepare_response() { if (!empty($this->function->returns_desc)) { $validatedvalues = external_api::clean_returnvalue($this->function->returns_desc, $this->returns); $encodingoptions = array( - "encoding" => "utf-8" + "encoding" => "utf-8", + "verbosity" => "no_white_space" ); // We can now convert the response to the requested XML-RPC format. $this->response = xmlrpc_encode_request(null, $validatedvalues, $encodingoptions); @@ -186,7 +187,8 @@ protected function generate_error(Exception $ex, $faultcode = 404) { ); $encodingoptions = array( - "encoding" => "utf-8" + "encoding" => "utf-8", + "verbosity" => "no_white_space" ); return xmlrpc_encode_request(null, $fault, $encodingoptions);