PHP Fatal error: Call to a member function getOriginalKeys() on a non-object in modules/contrib/search_api/contrib/search_api_facetapi/plugins/facetapi/adapter.inc on line 167

When I specify a longish string in the query like

/search?search_api_views_fulltext=ex1208312hex1208312hex1208312hex1208312hex1208312hex1208312hex1208312hex1208312hex1208312h234234234234234234234234234234234234234234

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drunken monkey’s picture

FileSize
636 bytes

Hm, sorry, I can neither reproduce nor explain this. What backend are you using? And about how long does the search string have to be?

Could you install the Devel module, apply the attached patch to the Search API and then report back what you're seeing when you try to reproduce the bug?

kyletaylored’s picture

I actually had this exact same issue yesterday. I don't know why, but what was happening was the Current Search block was showing up on non-search pages. Devel didn't do anything because nothing was being passed to $search. This helped me out.

kyletaylored’s picture

Issue summary: View changes

works even with a shorter string

sepehr.sadatifar’s picture

Issue summary: View changes

I get the same error when the path doesn't exists, for example when viewing http://site/products/clothes/socks I get this:
Fatal error: Call to a member function getOriginalKeys() on a non-object in modules/contrib/search_api/contrib/search_api_facetapi/plugins/facetapi/adapter.inc on line 174.
I checked "$search" variable and it's NULL.

drunken monkey’s picture

Title: PHP Fatal error: Call to a member function getOriginalKeys() when theres a long string in search » getSearchKeys() called even though getCurrentSearch() returns FALSE
Project: Search API » Facet API
Component: Facets » Code

The workaround from #2 would of course work for us. However, the actual issue seems to be deeper, i.e., in the Facet API. As I understand it, getSearchKeys() shouldn't be called if getCurrentSearch() returns FALSE (which should be the case here – but maybe you can debug that to make sure?). So, moving this to the Facet API queue for possible insights.

I still can't reproduce this, so have little chance of helping to debug.

@ sepehr.sadatifar: Do you maybe have some setup that executes a search on 404 pages, or some other special 404 mechanism?

cpliakas’s picture

getSearchKeys() shouldn't be called if getCurrentSearch() returns FALSE

To me that logic makes sense since there shouldn't be search keys if Fact API doesn't know about any searches. Let's double-check the code and figure out the fix.

sepehr.sadatifar’s picture

@drunken-monkey no module or custom code related to 404. the #2 patch works, I get no error just a page with no result.

sepehr.sadatifar’s picture

Status: Active » Reviewed & tested by the community

#2 patch seems ok and I think should be commited.

The last submitted patch, 1: 1670420--debugging-1.patch, failed testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 2: current-search-on-nonsearch-pages-1670420-2.patch, failed testing.

dorficus’s picture

I'm running into the same issue. I'm going to be re-submitting a patch based on #2, but current with the latest version.

dorficus’s picture

Project: Facet API » Search API
Component: Code » General code
FileSize
774 bytes

Moving this back to Search API since the issue is coming from the Search API file and the patch I'm uploading is attached to Search API

dorficus’s picture

Status: Needs work » Needs review
dorficus’s picture

drunken monkey’s picture

Project: Search API » Facet API
Component: General code » Code
Status: Needs review » Active

OK, since there hasn't been any activity in the issue on the Facet API side, I guess we might as well fix it on our side. (Should probably have done that right away, since it's a fatal error.)

So, thanks for re-rolling, and thanks again for the original patch, kyletaylored!
Committed.

Moving back to the Facet API, since the underlying issue remains.