diff options
author | Andreas Gohr <andi@splitbrain.org> | 2022-02-04 19:46:41 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2022-02-04 19:46:41 +0100 |
commit | 4b867325b0bce2a430cace11805d1b09c43f1ee1 (patch) | |
tree | bd8ce2361e05012ddbd020f30d3dad03bba65bc7 | |
parent | 6ad59578a04d11122174af79f51db238a68446dd (diff) | |
download | dokuwiki-4b867325b0bce2a430cace11805d1b09c43f1ee1.tar.gz dokuwiki-4b867325b0bce2a430cace11805d1b09c43f1ee1.zip |
Fix #3619 and correctly handle exceptions in XMLRPC
This ensures that any exception happening during XMLRPC processing is
signalled correctly to the client as XML encoded error message.
-rw-r--r-- | inc/Remote/XmlRpcServer.php | 5 | ||||
-rw-r--r-- | lib/exe/xmlrpc.php | 13 |
2 files changed, 13 insertions, 5 deletions
diff --git a/inc/Remote/XmlRpcServer.php b/inc/Remote/XmlRpcServer.php index bd70b51b8..394feafd2 100644 --- a/inc/Remote/XmlRpcServer.php +++ b/inc/Remote/XmlRpcServer.php @@ -19,6 +19,11 @@ class XmlRpcServer extends Server */ public function __construct($wait=false) { + global $conf; + if (!$conf['remote']) { + throw new ServerException("XML-RPC server not enabled.", -32605); + } + $this->remote = new Api(); $this->remote->setDateTransformation(array($this, 'toDate')); $this->remote->setFileTransformation(array($this, 'toFile')); diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index dc0438ee1..e90fb9eba 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -5,11 +5,14 @@ use dokuwiki\Remote\XmlRpcServer; -if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__).'/../../'); +if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../'); -require_once(DOKU_INC.'inc/init.php'); +require_once(DOKU_INC . 'inc/init.php'); session_write_close(); //close session -if(!$conf['remote']) die((new IXR_Error(-32605, "XML-RPC server not enabled."))->getXml()); - -$server = new XmlRpcServer(); +$server = new XmlRpcServer(true); +try { + $server->serve(); +} catch (\Exception $e) { + $server->error($e->getCode(), $e->getMessage()); +} |