aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/AppFramework
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/AppFramework')
-rw-r--r--lib/private/AppFramework/OCS/BaseResponse.php21
-rw-r--r--lib/private/AppFramework/OCS/V1Response.php8
-rw-r--r--lib/private/AppFramework/OCS/V2Response.php3
3 files changed, 16 insertions, 16 deletions
diff --git a/lib/private/AppFramework/OCS/BaseResponse.php b/lib/private/AppFramework/OCS/BaseResponse.php
index dbff1b846c1..d3904065102 100644
--- a/lib/private/AppFramework/OCS/BaseResponse.php
+++ b/lib/private/AppFramework/OCS/BaseResponse.php
@@ -37,13 +37,13 @@ abstract class BaseResponse extends Response {
/** @var string */
protected $format;
- /** @var string */
+ /** @var ?string */
protected $statusMessage;
- /** @var int */
+ /** @var ?int */
protected $itemsCount;
- /** @var int */
+ /** @var ?int */
protected $itemsPerPage;
/**
@@ -92,7 +92,7 @@ abstract class BaseResponse extends Response {
}
/**
- * @param string[] $meta
+ * @param array<string,string|int> $meta
* @return string
*/
protected function renderResult(array $meta): string {
@@ -125,12 +125,15 @@ abstract class BaseResponse extends Response {
return $writer->outputMemory(true);
}
- /**
- * @param array $array
- * @param \XMLWriter $writer
- */
- protected function toXML(array $array, \XMLWriter $writer) {
+ protected function toXML(array $array, \XMLWriter $writer): void {
foreach ($array as $k => $v) {
+ if ($k === '@attributes' && is_array($v)) {
+ foreach ($v as $k2 => $v2) {
+ $writer->writeAttribute($k2, $v2);
+ }
+ continue;
+ }
+
if (\is_string($k) && strpos($k, '@') === 0) {
$writer->writeAttribute(substr($k, 1), $v);
continue;
diff --git a/lib/private/AppFramework/OCS/V1Response.php b/lib/private/AppFramework/OCS/V1Response.php
index f4f19832fa8..cca3c267ec4 100644
--- a/lib/private/AppFramework/OCS/V1Response.php
+++ b/lib/private/AppFramework/OCS/V1Response.php
@@ -28,7 +28,6 @@ use OCP\AppFramework\Http;
use OCP\AppFramework\OCSController;
class V1Response extends BaseResponse {
-
/**
* The V1 endpoint has very limited http status codes basically everything
* is status 200 except 401
@@ -69,12 +68,11 @@ class V1Response extends BaseResponse {
$meta = [
'status' => $this->getOCSStatus() === 100 ? 'ok' : 'failure',
'statuscode' => $this->getOCSStatus(),
- 'message' => $this->getOCSStatus() === 100 ? 'OK' : $this->statusMessage,
+ 'message' => $this->getOCSStatus() === 100 ? 'OK' : $this->statusMessage ?? '',
+ 'totalitems' => (string)($this->itemsCount ?? ''),
+ 'itemsperpage' => (string)($this->itemsPerPage ?? ''),
];
- $meta['totalitems'] = $this->itemsCount !== null ? (string)$this->itemsCount : '';
- $meta['itemsperpage'] = $this->itemsPerPage !== null ? (string)$this->itemsPerPage: '';
-
return $this->renderResult($meta);
}
}
diff --git a/lib/private/AppFramework/OCS/V2Response.php b/lib/private/AppFramework/OCS/V2Response.php
index 6c302698bc9..8bf4c37a578 100644
--- a/lib/private/AppFramework/OCS/V2Response.php
+++ b/lib/private/AppFramework/OCS/V2Response.php
@@ -27,7 +27,6 @@ use OCP\AppFramework\Http;
use OCP\AppFramework\OCSController;
class V2Response extends BaseResponse {
-
/**
* The V2 endpoint just passes on status codes.
* Of course we have to map the OCS specific codes to proper HTTP status codes
@@ -61,7 +60,7 @@ class V2Response extends BaseResponse {
$meta = [
'status' => $status >= 200 && $status < 300 ? 'ok' : 'failure',
'statuscode' => $this->getOCSStatus(),
- 'message' => $status >= 200 && $status < 300 ? 'OK' : $this->statusMessage,
+ 'message' => $status >= 200 && $status < 300 ? 'OK' : $this->statusMessage ?? '',
];
if ($this->itemsCount !== null) {