From 4ac0375f89cdbfc8ae7fc8d199cf0dd55079cb8a Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Fri, 1 Mar 2019 10:29:17 -0100 Subject: cleaning the excerpts managment Signed-off-by: Maxence Lange --- lib/private/FullTextSearch/Model/IndexDocument.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'lib/private/FullTextSearch/Model') diff --git a/lib/private/FullTextSearch/Model/IndexDocument.php b/lib/private/FullTextSearch/Model/IndexDocument.php index fec140c81a0..55cce902a28 100644 --- a/lib/private/FullTextSearch/Model/IndexDocument.php +++ b/lib/private/FullTextSearch/Model/IndexDocument.php @@ -671,12 +671,11 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * @return IIndexDocument */ final public function addExcerpt(string $source, string $excerpt): IIndexDocument { - $excerpt = $this->cleanExcerpt($excerpt); - if (!array_key_exists($source, $this->excerpts)) { - $this->excerpts[$source] = []; - } - - $this->excerpts[$source][] = $excerpt; + $this->excerpts[] = + [ + 'source' => $source, + 'excerpt' => $this->cleanExcerpt($excerpt) + ]; return $this; } @@ -694,13 +693,9 @@ class IndexDocument implements IIndexDocument, JsonSerializable { final public function setExcerpts(array $excerpts): IIndexDocument { $new = []; foreach ($excerpts as $entry) { - $newExcerpts = array_map(function (string $excerpt): string { - return $this->cleanExcerpt($excerpt); - }, $entry['excerpt']); - $new[] = [ 'source' => $entry['source'], - 'excerpt' => $newExcerpts + 'excerpt' => $this->cleanExcerpt($entry['excerpt']) ]; } -- cgit v1.2.3