Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two issues after upgrading PHP and TNTSearch - nostemmerstemmer and curly braces #261

Open
rkyoku opened this issue Jan 19, 2022 · 1 comment

Comments

@rkyoku
Copy link

rkyoku commented Jan 19, 2022

Hi there!

After upgrading PHP (7.4.27) and TNTSearch (using @stable), I am experiencing multiple issues that prevent me from going live.

nostemmerStemmer

I get the error:

Fatal error: Uncaught Error:
Class 'TeamTNT\TNTSearch\Stemmer\Teamtnt\tntsearch\stemmer\nostemmerStemmer' not found
    in /media/webapps/project/lib/vendor/teamtnt/tntsearch/src/TNTSearch.php:264
Stack trace:
    #0 /media/webapps/project/lib/vendor/teamtnt/tntsearch/src/TNTSearch.php(35):
        TeamTNT\TNTSearch\TNTSearch->setStemmer()

My code:

$this->_tnt->loadConfig([
    'storage' => $sPath,
    // 'stemmer' => \TeamTNT\TNTSearch\Stemmer\NoStemmer::class // PorterStemmer
]);
$this->_tnt->selectIndex('Product');

Please note that it doesn't matter that I choose a Stemmer or not, and which one. I get the same error no matter what.

Maybe the stemmer full class name was stored in the data, and with this new version, the way of storing/using it changed, and the backward compatibility was somehow imperfect?

SELECT * FROM info WHERE key = 'stemmer' gives TeamTNT\TNTSearch\Stemmer\NoStemmer, which is then strtolowered etc.

But, seeing how it is used, I think removing the namespaces and also the pending "stemmer" would work fine, and be backward compatible.

Curly braces

Finally, for the biggest issue if I may: I told myself "maybe my data is too old and incompatible with this new version of TNTSearch, I ought to build it again".

But then, when I tried, I got the error:

PHP Fatal error:  Uncaught ErrorException:
    Array and string offset access syntax with curly braces is deprecated
    in /media/webapps/project/lib/vendor/teamtnt/tntsearch/src/Stemmer/PorterStemmer.php:382

Which prevents me from building the data again.

However, curly braces access was deprecated in PHP 7.4 (nov. 2019). But the composer.json file indicates that TNTSearch is compatible with PHP up to version 8.

Is there a configuration that I should modify in my php.ini for this to work?


All in all, is there something I did wrong? What should I do?

I'd like to avoid cloning the repo if possible.

Thanks!

Best,

@nticaric
Copy link
Contributor

You can create a PR for the porter stemmer and replace the offset access syntax with curly braces

Like this:

 $var[$idx] instead of $var{$idx}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants