Permalink
Browse files

Fix serializer: never add a "chunk" if there was already a proper XML…

…Doc.
  • Loading branch information...
1 parent 9ac73a7 commit 9dda916de832de494153110e4b78b7a57715e2cf @cdujeu cdujeu committed Sep 29, 2016
Showing with 14 additions and 8 deletions.
  1. +14 −8 core/src/core/src/pydio/Core/Http/Response/SerializableResponseStream.php
@@ -172,14 +172,20 @@ protected function serializeData($data, $serializer){
$wrap = true;
$buffer = "";
$charset = null;
- foreach ($data as $serializableItem){
- if(!$serializableItem instanceof XMLSerializableResponseChunk){
- continue;
- }
- $buffer .= $serializableItem->toXML();
- if($serializableItem instanceof XMLDocSerializableResponseChunk){
- $wrap = false;
- $charset = $serializableItem->getCharset();
+ /** @var XMLDocSerializableResponseChunk[] $xmlDocs */
+ $xmlDocs = array_filter($data, function($serial){
+ return $serial instanceof XMLDocSerializableResponseChunk;
+ });
+ if(count($xmlDocs)){
+ $buffer = $xmlDocs[0]->toXML();
+ $charset = $xmlDocs[0]->getCharset();
+ $wrap = false;
+ }else{
+ foreach ($data as $serializableItem){
+ if(!$serializableItem instanceof XMLSerializableResponseChunk){
+ continue;
+ }
+ $buffer .= $serializableItem->toXML();
}
}

0 comments on commit 9dda916

Please sign in to comment.