Problem/Motivation
After switching to PHP 8.0 version and while trying to index data, it throws the following issue with the Normalize tokens function, which causes the website indexing to break.
TypeError. Cannot access offset of type string on string in SearchApiAbstractProcessor->normalize Tokens) (line 297 of /var/www/default/htdocs/httpdocs/sites/all/modules/contrib/search_api/includes/processor.inc).
Steps to reproduce
- Switch to PHP 8.0 version
- Try to Index node content with tokens
- And while indexing it breaks the process of indexing
Proposed resolution
Adding condition to check for if $tokens is array before normalising tokens.
Remaining tasks
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | normalizetokens-issue-3372728-5.patch | 554 bytes | hitesh-jain |
| #3 | normalizetokens-issue-3372728-3.patch | 0 bytes | hitesh-jain |
| 2023-07-04_10-25.png | 52.55 KB | hitesh-jain |
Issue fork search_api-3372728
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
hitesh-jain commentedFixing issue with PHP 8.0 version adding additional check for $tokens.
Comment #4
hitesh-jain commentedComment #5
hitesh-jain commentedReadding patch
Comment #6
drunken monkeyThanks for reporting this problem!
The additional check seems innocent enough. I’d advise you to still try and find out where the unexpected token value is coming from and whether that code, along with the fix in this issue, produces the right result. Otherwise, this fix might just shadow some underlying issue for you.
Anyways, merged this. Thanks again!