summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-03 18:49:44 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-03 18:49:44 +0100
commitc694c8477dd0a46a9697d8f4db97934a6aaa23ba (patch)
treee224c29484eb58ee6f17d2c64ade4a3335a299e1
parent4a3fcb583cbe52466d2e935caf65f1103c196692 (diff)
downloadsearch-c694c8477dd0a46a9697d8f4db97934a6aaa23ba.tar.gz
search-c694c8477dd0a46a9697d8f4db97934a6aaa23ba.tar.bz2
search-c694c8477dd0a46a9697d8f4db97934a6aaa23ba.zip
search: always use syllable expansion; fix PHP 8 null arithmetic
- 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 <noreply@anthropic.com>
-rwxr-xr-xincludes/classes/SearchLib.php10
1 files 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