X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/7d0724e2888f768149b425efcdc185a1c7a4be02..refs/pull/3072/head:/app/Entities/Tools/SearchIndex.php diff --git a/app/Entities/Tools/SearchIndex.php b/app/Entities/Tools/SearchIndex.php index 3c4b5a247..79139ec24 100644 --- a/app/Entities/Tools/SearchIndex.php +++ b/app/Entities/Tools/SearchIndex.php @@ -67,7 +67,7 @@ class SearchIndex * - The number that have been processed so far. * - The total number of that model to be processed. * - * @param callable(Entity, int, int)|null $progressCallback + * @param callable(Entity, int, int):void|null $progressCallback */ public function indexAllEntities(?callable $progressCallback = null) { @@ -175,7 +175,7 @@ class SearchIndex $names = []; $values = []; - foreach($tags as $tag) { + foreach ($tags as $tag) { $names[] = $tag->name; $values[] = $tag->value; } @@ -223,7 +223,7 @@ class SearchIndex if ($entity instanceof Page) { $bodyTermsMap = $this->generateTermScoreMapFromHtml($entity->html); } else { - $bodyTermsMap = $this->generateTermScoreMapFromText($entity->description, $entity->searchFactor); + $bodyTermsMap = $this->generateTermScoreMapFromText($entity->description ?? '', $entity->searchFactor); } $mergedScoreMap = $this->mergeTermScoreMaps($nameTermsMap, $bodyTermsMap, $tagTermsMap); @@ -233,17 +233,16 @@ class SearchIndex $entityType = $entity->getMorphClass(); foreach ($mergedScoreMap as $term => $score) { $dataArray[] = [ - 'term' => $term, - 'score' => $score, + 'term' => $term, + 'score' => $score, 'entity_type' => $entityType, - 'entity_id' => $entityId, + 'entity_id' => $entityId, ]; } return $dataArray; } - /** * For the given term data arrays, Merge their contents by term * while combining any scores.