aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKate <26026535+provokateurin@users.noreply.github.com>2023-06-13 13:30:55 +0200
committerGitHub <noreply@github.com>2023-06-13 13:30:55 +0200
commit38d64f45be4df196945851b0a931747614670be5 (patch)
treec18bfaa6021039bb3fbb79ed37ae19a33585805e
parent3f766e90affe5be78444be591eec28fd43e19a43 (diff)
parent7f4651637a96a93b8b0479834b5058480380d0fa (diff)
downloadnextcloud-server-38d64f45be4df196945851b0a931747614670be5.tar.gz
nextcloud-server-38d64f45be4df196945851b0a931747614670be5.zip
Merge pull request #38745 from nextcloud/feature/ocs-xml-stdclass
Allow stdClass in XML responses
-rw-r--r--lib/private/AppFramework/OCS/BaseResponse.php4
-rw-r--r--tests/lib/AppFramework/OCS/BaseResponseTest.php3
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/private/AppFramework/OCS/BaseResponse.php b/lib/private/AppFramework/OCS/BaseResponse.php
index 1191b861278..533cff74a30 100644
--- a/lib/private/AppFramework/OCS/BaseResponse.php
+++ b/lib/private/AppFramework/OCS/BaseResponse.php
@@ -143,6 +143,10 @@ abstract class BaseResponse extends Response {
$k = 'element';
}
+ if ($v instanceof \stdClass) {
+ $v = [];
+ }
+
if (\is_array($v)) {
$writer->startElement($k);
$this->toXML($v, $writer);
diff --git a/tests/lib/AppFramework/OCS/BaseResponseTest.php b/tests/lib/AppFramework/OCS/BaseResponseTest.php
index 9038aee6baf..a1e0c620574 100644
--- a/tests/lib/AppFramework/OCS/BaseResponseTest.php
+++ b/tests/lib/AppFramework/OCS/BaseResponseTest.php
@@ -45,13 +45,14 @@ class BaseResponseTest extends \Test\TestCase {
'someElement' => 'withAttribute',
],
'value without key',
+ 'object' => new \stdClass(),
];
$this->invokePrivate($response, 'toXml', [$data, $writer]);
$writer->endDocument();
$this->assertEquals(
- "<?xml version=\"1.0\"?>\n<hello>hello</hello><information test=\"some data\"><someElement>withAttribute</someElement></information><element>value without key</element>\n",
+ "<?xml version=\"1.0\"?>\n<hello>hello</hello><information test=\"some data\"><someElement>withAttribute</someElement></information><element>value without key</element><object/>\n",
$writer->outputMemory(true)
);
}