Skip to content

Commit

Permalink
Allow stdClass in XML responses
Browse files Browse the repository at this point in the history
Signed-off-by: jld3103 <jld3103yt@gmail.com>
  • Loading branch information
provokateurin committed Jun 12, 2023
1 parent a85831a commit 2a75103
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/private/AppFramework/OCS/BaseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ protected function toXML(array $array, \XMLWriter $writer): void {
$k = 'element';
}

if ($v instanceof \stdClass) {
$v = [];
}

if (\is_array($v)) {
$writer->startElement($k);
$this->toXML($v, $writer);
Expand Down
1 change: 1 addition & 0 deletions tests/lib/AppFramework/OCS/BaseResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function testToXml(): void {
'someElement' => 'withAttribute',
],
'value without key',
'object' => new \stdClass(),
];

$this->invokePrivate($response, 'toXml', [$data, $writer]);
Expand Down

0 comments on commit 2a75103

Please sign in to comment.