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

  1. Switch to PHP 8.0 version
  2. Try to Index node content with tokens
  3. 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

Issue fork search_api-3372728

Command icon 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

hitesh-jain created an issue. See original summary.

hitesh-jain’s picture

StatusFileSize
new0 bytes

Fixing issue with PHP 8.0 version adding additional check for $tokens.

hitesh-jain’s picture

Status: Active » Needs review
hitesh-jain’s picture

StatusFileSize
new554 bytes

Readding patch

drunken monkey’s picture

Status: Needs review » Fixed

Thanks 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!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.