From c694c8477dd0a46a9697d8f4db97934a6aaa23ba Mon Sep 17 00:00:00 2001 From: Lester Caine Date: Wed, 3 Jun 2026 18:49:44 +0100 Subject: search: always use syllable expansion; fix PHP 8 null arithmetic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove broken $plUsePart gate (literal $ in key meant it never fired); syllable expansion now always runs so partial terms like 'TLC' expand to indexed words like 'tlc5917n' - Cast getOne() to int before time() subtraction — PHP 8 rejects int-null arithmetic when syllable row doesn't exist yet Co-Authored-By: Claude Sonnet 4.6 --- includes/classes/SearchLib.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/includes/classes/SearchLib.php b/includes/classes/SearchLib.php index 821443d..05fd392 100755 --- a/includes/classes/SearchLib.php +++ b/includes/classes/SearchLib.php @@ -49,11 +49,9 @@ class SearchLib extends BitBase { public function find( &$pParamHash ) { // $where, $words, $offset, $max_records, $plUsePart = false) { $pParamHash['words'] = preg_split("/[\W]+/", strtolower($pParamHash['words']), -1, PREG_SPLIT_NO_EMPTY); - if ( isset($pParamHash['$plUsePart']) && $pParamHash['$plUsePart'] ) { - $wordList = $this->get_wordlist_from_syllables( $pParamHash['words'] ); - if ([ $wordList ] ) { - $pParamHash['words'] = array_merge( $pParamHash['words'], $wordList ); - } + $wordList = $this->get_wordlist_from_syllables( $pParamHash['words'] ); + if( !empty( $wordList ) ) { + $pParamHash['words'] = array_unique( array_merge( $pParamHash['words'], $wordList ) ); } $res = $this->find_exact_generic( $pParamHash ); return $res; @@ -70,7 +68,7 @@ class SearchLib extends BitBase { $ret = []; foreach($syllables as $syllable) { $bindvars = [ $syllable ]; - $age = time() - $this->mDb->getOne( + $age = time() - (int)$this->mDb->getOne( "select `last_updated` from `" . BIT_DB_PREFIX . "search_syllable` where `syllable`=?", $bindvars, ); if(!$age || $age > ($search_syll_age * 3600)) {// older than search_syll_age hours -- cgit v1.3