From a66d62d1d70932efb7ac4871882974e528f1e139 Mon Sep 17 00:00:00 2001 From: Benjamin Brahmer Date: Sat, 6 Aug 2022 11:29:46 +0200 Subject: adapt generateSearchIndex Signed-off-by: Benjamin Brahmer --- lib/Db/Item.php | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/lib/Db/Item.php b/lib/Db/Item.php index b30bd31cf..4fe9bc19c 100644 --- a/lib/Db/Item.php +++ b/lib/Db/Item.php @@ -170,16 +170,28 @@ class Item extends Entity implements IAPI, \JsonSerializable ? implode('', $this->getCategories()) : ''; - $this->setSearchIndex( - mb_strtolower( - html_entity_decode(strip_tags($this->getBody())) . - html_entity_decode($this->getAuthor()) . - html_entity_decode($this->getTitle()) . - html_entity_decode($categoriesString) . - $this->getUrl(), - 'UTF-8' - ) - ); + if (!is_null($this->getBody())) { + $stripedBody = strip_tags($this->getBody()); + } else { + $stripedBody = ""; + } + + $input_list = array($stripedBody, $this->getAuthor(), $this->getTitle(), $categoriesString); + + $search_string = ""; + + foreach ($input_list as $value) { + if (is_null($value)){ + $search_string .= ""; + } else { + html_entity_decode($value); + } + } + + $search_string .= $this->getUrl(); + $search_string .= 'UTF-8'; + + $this->setSearchIndex(mb_strtolower($search_string)); $this->setFingerprint($this->computeFingerprint()); $this->setContentHash($this->computeContentHash()); } -- cgit v1.2.3