]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix serializing indexed unified search array as object 22806/head
authorChristoph Wurst <christoph@winzerhof-wurst.at>
Fri, 11 Sep 2020 13:57:04 +0000 (15:57 +0200)
committerChristoph Wurst <christoph@winzerhof-wurst.at>
Fri, 11 Sep 2020 13:57:04 +0000 (15:57 +0200)
We expect an array of results from the search provider. If the search
provider returns an array with indexes, php will serialize it as object,
not as array (to preserve the keys). The client doesn't need this info,
so we should just discard it and take the values only to always render a
JSON array.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
lib/public/Search/SearchResult.php

index 1a07f24b33a13b4d1a743910d41ccad6aacf3733..e70c70f1aaa56a5be23c38faa6030a92b8706d7d 100644 (file)
@@ -28,6 +28,7 @@ declare(strict_types=1);
 namespace OCP\Search;
 
 use JsonSerializable;
+use function array_values;
 
 /**
  * @since 20.0.0
@@ -107,7 +108,7 @@ final class SearchResult implements JsonSerializable {
                return [
                        'name' => $this->name,
                        'isPaginated' => $this->isPaginated,
-                       'entries' => $this->entries,
+                       'entries' => array_values($this->entries),
                        'cursor' => $this->cursor,
                ];
        }