Problem/Motivation
The SearchApiCachePluginTrait doesn't account for when an index is disabled, but there's still an attempt to query it. This results in a 500 error.
Steps to reproduce
- Create a View that uses that index. Best create a page display.
- Create some content to be indexed by the server.
- Disable the server.
- Access the page display of the View. The requets should result in a 500 error.
Proposed resolution
In SearchApiCachePluginTrait::cacheSet(), add a check to see if $searchApiSearchQuery is set before using it.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3564177-1.patch | 1.54 KB | albionbrown |
Issue fork search_api-3564177
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 #2
albionbrown commentedComment #5
drunken monkeyThanks for reporting this problem and already providing a patch!
We now use MR for working on changes, though – I created one with the changes from your patch and also added test coverage.
Just one more question, otherwise I think this is ready to be merged: Your patch also contains changes to
SearchApiMoreLikeThis. Are these related and also necessary or did you just include them by mistake? In the former case, could you quickly explain why those are needed?PS: It seems you (like many others – it's really easy to misinterpret) are confused by the "Issue tags" field. As the guidelines state, they aren't meant for free text tags related to the issue, but only for specific categorization purposes, usually by module maintainers.
So, if you aren't sure your current usage is correct, please just leave the field empty.
Comment #6
jvollebregt-swis commentedFound this issue when searching for my error. I'm getting a
Call to a member function setOption() on nullinSearchApiMoreLikeThis::querywhich was fixed by the patch. I presume it was deliberate.Not sure if checking the index is the more robust solution instead of just checking if
getSearchApiQuery()returns anything like the patch does inSearchApiCachePluginTraitbut it works in my case.