teamtnt / tntsearch

A fully featured full text search engine written in PHP
https://tnt.studio/solving-the-search-problem-with-laravel-and-tntsearch
MIT License
3.1k stars 291 forks source link

Notice: Trying to access array offset on value of type bool (after upgrading to php7.4) #199

Open dirkjf opened 4 years ago

dirkjf commented 4 years ago

After upgrading to PHP 7.4 I get a:

Notice: Trying to access array offset on value of type bool

on the search method when using:


$tnt = new TNTSearch();
$results = $tnt->search('example string', 100);```
dirkjf commented 4 years ago

I rolled back PHP to version 7.3.12 to confirm the problem is linked to PHP 7.4. On 7.3.12 everything works as expected.

iambudi commented 4 years ago

I also found two kind of errors in PHP 7.4 related to searching in Grav CMS:

  1. TNTSearch Line 401 : Fixed by using ?? Operator
    return $docs->fetch(PDO::FETCH_ASSOC)['value'] ?? "";
  2. PorterStemmer line 396 and 416. Fixed by replacing {} with []
    
    // Line 396
    return preg_match("#$c{2}$#", $str, $matches) && $matches[0][0] == $matches[0][1];

// Line 416 if (in_array($matches[1][2], ['w', 'x', 'y'])) { $return = false; }



Hope this help.
jatinbphp commented 1 year ago

Hello,

I am facing same issue in php 7.4. I tried @iambudi 's solution but in TNTSearch.php, there is only 320lines of code, so where to do his changes ?

howdu commented 4 weeks ago

This is the stack trace if it helps. Not sure if it's error in implementation?

EDIT: fixed my issue turned out to be a nullable column issue caused higher up the chain.

Screenshot 2024-11-04 at 18 03 28