tntsearch
tntsearch copied to clipboard
Notice: Trying to access array offset on value of type bool (after upgrading to php7.4)
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);```
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.
I also found two kind of errors in PHP 7.4 related to searching in Grav CMS:
- TNTSearch Line 401 : Fixed by using
??
Operator
return $docs->fetch(PDO::FETCH_ASSOC)['value'] ?? "";
- 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.
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 ?