Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem:
Invalid argument supplied for foreach() service.inc:1638
SearchApiQueryFilter::getTags() can sometimes return NULL. That happens with Search API Sqaved Searches where SearchApiQueryFilter objects are serialized into the database. Old serialized objects have NULL on their tags property.
The method_exists() call also does not make sense in createFilterQueries() because the type hint to SearchApiQueryFilterInterface already enforces that the getTags() method is always there.
Comment | File | Size | Author |
---|---|---|---|
#5 | 2837745-5.patch | 425 bytes | drunken monkey |
|
Comments
Comment #2
klausiPatch.
Comment #3
drunken monkeyThanks for reporting this issue! Seems we forgot to think about old serialized queries/filters when implementing this. Easy to miss, I guess.
However, instead of checking for an illegal return value in the Solr backend, I think we should just eliminate the root cause: the
getTags()
says it'll always return an array, so it should. Patch attached.Regading removal of
method_exists()
: that's still needed in case someone updates the Solr module but has an outdated Search API module. "Don't do that!" is of course the right answer, but I think we both know that it'll still happen.Comment #4
klausiMakes sense!
So the method returns by reference, but you return an array which is not a reference to $this->tags.
You should set $this->tags to the empty array first and then return that.
Comment #5
drunken monkeyCorrect, of course – thanks for catching that!
Otherwise, would you say this is RTBC?
Comment #7
drunken monkeyShould be fine, so: committed.
Thanks again for reporting!