I ran into an issue when running drush sapi-i . So when I am indexing, I noticed these message(s) (using PHP7.1) :

  • "Illegal string offset 'value' processor.inc:331"

it happens in :

  protected function implodeTokens(array $tokens) {
    $ret = array();
    foreach ($tokens as $token) {
      if (empty($token['value']) && !is_numeric($token['value'])) {
        // Filter out empty tokens.
        continue;
      }
      if (is_array($token['value'])) {
        $ret[] = $this->implodeTokens($token['value']);
      }
      else {
        $ret[] = $token['value'];
      }
    }
    return implode(' ', $ret);
  }

Sometimes the token just consists out of numbers/id's , example :

array(5) {
  [0]=>
  string(4) "1485"
  [1]=>
  string(4) "1599"
  [2]=>
  string(4) "1501"
  [3]=>
  string(4) "1503"
  [4]=>
  string(4) "1481"
}

so I have added an extra check to only process when the key 'value' exists.

CommentFileSizeAuthor
#2 search_api-n2976563-2.patch1016 bytessiggy

Comments

Siggy created an issue. See original summary.

siggy’s picture

StatusFileSize
new1016 bytes

Added patch for the function implodeTokens.

I might be usefull for normalizeTokens aswell (looks similar).

siggy’s picture

Version: 7.x-1.17 » 7.x-1.18
drunken monkey’s picture

Component: General code » Plugins
Status: Active » Postponed (maintainer needs more info)

The system is certainly a bit fragile, but the way we defined our "tokens" type is that they always need to have a nested 'value' key. If they don't, the bug is not that it's not handled properly, but whatever code tokenized the text (or changed existing tokens). Can you find out where this happens for you? Do you maybe have some custom processors active, or ones from other contrib modules?

drunken monkey’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Closed due to long time without response.
Please re-open with the requested information if still relevant.