When a Search API search view is used (search is performed), the following error is thrown in the drupal log:
Warning: count(): Parameter must be an array or an object that implements Countable in Drupal\search_api\Plugin\search_api\processor\Highlight->highlightField() (line 625 of search_api/src/Plugin/search_api/processor/Highlight.php)
PHP version we use on this website where this error occurs is 7.3.15. The search still works, but this error is thrown on every search and on high traffic websites this can quickly flood the logs.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3115343-3--highlighting_pcre_error.patch | 1.38 KB | drunken monkey |
Comments
Comment #2
klemendev commentedThis issue can be fixed by setting Highlight returned field data parameter from Always to If the server returns fields.
I am not sure if this is meant to be this way or not so I am leaving this ticket open for one of the developers to confirm if this is normal or not.
Comment #3
drunken monkeyVery strange, this seems to indicate a failure in the regular expression evaluation.
The attached patch should both detect this problem and add a more helpful log message for the problem. (Which, admittedly, will still flood your logs, I guess.) Could you please try it and tell me what it says? (Or whether it doesn’t work at all?)
Comment #4
klemendev commentedI have changed the configuration of the search engine quite a lot from the time of reporting this bug and this is no longer happening, unfortunately.
Comment #5
pcate commentedI've been seeing this error in our logs as well. Here's a stack trace from new relic:
Comment #6
drunken monkeyThanks a lot for chiming in, PCate! Unfortunately, the stack trace doesn’t really bring any extra information here. Could you tell me what happens when you apply the patch, what message you get in your logs then?
Comment #7
drunken monkeyOK, then let’s just commit and see the error message when someone files a bug report for it. ;)
Comment #10
odai atiehI have the same issue, and you can find more info in the below:
Message: A PCRE error (#2) occurred during results highlighting.
I fixed the issue by changing the settings of the Highlight:
Highlight returned field data -> If the server returns fields