aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2024-01-05 17:15:35 +0100
committerAndreas Gohr <andi@splitbrain.org>2024-01-07 13:41:19 +0100
commitb433b69e7dcd75265f237b6637ab5f34a7c40a74 (patch)
tree1797a8388aac9169e799c8bfc110e5cf2e689500
parentd3856637cf1c8c054f0b89e003bfed5bff1b60f9 (diff)
downloaddokuwiki-b433b69e7dcd75265f237b6637ab5f34a7c40a74.tar.gz
dokuwiki-b433b69e7dcd75265f237b6637ab5f34a7c40a74.zip
API: remove file and date transformations
We always deal with timestamps or base64 now. Removing some of the magic makes everything less complex. Only affected plugin is confmanager, which needs an update.
-rw-r--r--inc/Remote/Api.php69
-rw-r--r--inc/Remote/JsonRpcServer.php10
-rw-r--r--inc/Remote/XmlRpcServer.php20
3 files changed, 2 insertions, 97 deletions
diff --git a/inc/Remote/Api.php b/inc/Remote/Api.php
index d258d59b4..00e28a07f 100644
--- a/inc/Remote/Api.php
+++ b/inc/Remote/Api.php
@@ -4,6 +4,7 @@ namespace dokuwiki\Remote;
use dokuwiki\Extension\RemotePlugin;
use dokuwiki\Logger;
+use dokuwiki\test\Remote\MockApiCore;
/**
* This class provides information about remote access to the wiki.
@@ -42,18 +43,6 @@ class Api
/** @var ApiCall[] remote methods provided by dokuwiki plugins */
protected $pluginMethods;
- private $dateTransformation;
- private $fileTransformation;
-
- /**
- * constructor
- */
- public function __construct()
- {
- $this->dateTransformation = [$this, 'dummyTransformation'];
- $this->fileTransformation = [$this, 'dummyTransformation'];
- }
-
/**
* Get all available methods with remote access.
*
@@ -67,7 +56,7 @@ class Api
/**
* Collects all the core methods
*
- * @param ApiCore|\RemoteAPICoreTest $apiCore this parameter is used for testing.
+ * @param ApiCore|MockApiCore $apiCore this parameter is used for testing.
* Here you can pass a non-default RemoteAPICore instance. (for mocking)
* @return ApiCall[] all core methods.
*/
@@ -188,58 +177,4 @@ class Api
// still here? no can do
throw new AccessDeniedException('server error. not authorized to call method', -32604);
}
-
- /**
- * Transform file to xml
- *
- * @param mixed $data
- * @return mixed
- */
- public function toFile($data)
- {
- return call_user_func($this->fileTransformation, $data);
- }
-
- /**
- * Transform date to xml
- *
- * @param mixed $data
- * @return mixed
- */
- public function toDate($data)
- {
- return call_user_func($this->dateTransformation, $data);
- }
-
- /**
- * A simple transformation
- *
- * @param mixed $data
- * @return mixed
- */
- public function dummyTransformation($data)
- {
- return $data;
- }
-
- /**
- * Set the transformer function
- *
- * @param callback $dateTransformation
- */
- public function setDateTransformation($dateTransformation)
- {
- $this->dateTransformation = $dateTransformation;
- }
-
- /**
- * Set the transformer function
- *
- * @param callback $fileTransformation
- */
- public function setFileTransformation($fileTransformation)
- {
- $this->fileTransformation = $fileTransformation;
- }
-
}
diff --git a/inc/Remote/JsonRpcServer.php b/inc/Remote/JsonRpcServer.php
index 0708eb96f..f92942771 100644
--- a/inc/Remote/JsonRpcServer.php
+++ b/inc/Remote/JsonRpcServer.php
@@ -18,7 +18,6 @@ class JsonRpcServer
public function __construct()
{
$this->remote = new Api();
- $this->remote->setFileTransformation([$this, 'toFile']);
}
/**
@@ -183,13 +182,4 @@ class JsonRpcServer
throw $e;
}
}
-
- /**
- * @param string $data
- * @return string
- */
- public function toFile($data)
- {
- return base64_encode($data);
- }
}
diff --git a/inc/Remote/XmlRpcServer.php b/inc/Remote/XmlRpcServer.php
index e41b5d791..9985fe760 100644
--- a/inc/Remote/XmlRpcServer.php
+++ b/inc/Remote/XmlRpcServer.php
@@ -20,8 +20,6 @@ class XmlRpcServer extends Server
public function __construct($wait = false)
{
$this->remote = new Api();
- $this->remote->setDateTransformation([$this, 'toDate']);
- $this->remote->setFileTransformation([$this, 'toFile']);
parent::__construct(false, false, $wait);
}
@@ -68,22 +66,4 @@ class XmlRpcServer extends Server
return new ServerException($e->getMessage(), $e->getCode());
}
}
-
- /**
- * @param string|int $data iso date(yyyy[-]mm[-]dd[ hh:mm[:ss]]) or timestamp
- * @return Date
- */
- public function toDate($data)
- {
- return new Date($data);
- }
-
- /**
- * @param string $data
- * @return Base64
- */
- public function toFile($data)
- {
- return new Base64($data);
- }
}