summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorCôme Chilliet <91878298+come-nc@users.noreply.github.com>2023-01-20 11:43:24 +0100
committerGitHub <noreply@github.com>2023-01-20 11:43:24 +0100
commit37bb33c5799b834dfef3fb73936bd0e5a4773fb8 (patch)
tree0c7dd249075d8bb435589481b1e671e0a3fdbc54 /lib/private
parentfce87f8ddb2d523a503051362a66b7453bc2329b (diff)
parentf32d18d4ea371dbf2ec04c254f91abfd0fa3f4b9 (diff)
downloadnextcloud-server-37bb33c5799b834dfef3fb73936bd0e5a4773fb8.tar.gz
nextcloud-server-37bb33c5799b834dfef3fb73936bd0e5a4773fb8.zip
Merge pull request #34997 from nextcloud/fix/drop-php-7.4
Drop PHP 7.4 on master
Diffstat (limited to 'lib/private')
-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
-rw-r--r--lib/private/legacy/OC_API.php2
4 files changed, 17 insertions, 17 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) {
diff --git a/lib/private/legacy/OC_API.php b/lib/private/legacy/OC_API.php
index 46ee3495572..0da546f3263 100644
--- a/lib/private/legacy/OC_API.php
+++ b/lib/private/legacy/OC_API.php
@@ -101,7 +101,7 @@ class OC_API {
public static function requestedFormat(): string {
$formats = ['json', 'xml'];
- $format = (isset($_GET['format']) && in_array($_GET['format'], $formats)) ? $_GET['format'] : 'xml';
+ $format = (isset($_GET['format']) && is_string($_GET['format']) && in_array($_GET['format'], $formats)) ? $_GET['format'] : 'xml';
return $format;
}