Recoverable fatal error: Argument 2 passed to apachesolr_search_process_response() must implement interface DrupalSolrQueryInterface, null given in apachesolr_search_process_response()

apachesolr_search_run() does the following:
list($final_query, $response) = apachesolr_do_query($query);

It then passes $final_query to apachesolr_search_process_response() (by default) which, as the error indicates, requires that its $query argument implements DrupalSolrQueryInterface.

The problem is that if a hook_apachesolr_query_alter() implementation aborted the query by setting $query->abort_search to TRUE, then apachesolr_do_query() returns array(NULL, array());

i.e. $final_query is NULL, rather than an object implementing DrupalSolrQueryInterface.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jweowu’s picture

Issue summary: View changes
jweowu’s picture

Issue summary: View changes
jweowu’s picture

Issue summary: View changes
jweowu’s picture

Status: Active » Needs review
FileSize
748 bytes
Erik Frèrejean’s picture

The patch by jweowu doesn't actually resolve the issue because the return value of `apachesolr_search_run` is an array containing the search results rather then a response object.

I've attached a patch that returns the correct result set and rectifies the docblock.

jweowu’s picture

Status: Needs review » Reviewed & tested by the community

Thanks Erik, you're quite right.

It's curious that the initial version wasn't at least throwing a notice somewhere ('empty' objects are neither empty() nor FALSE after all, so it wouldn't have been trivially passing a test like that); but it does look very much as if an array is correct here.

(Ah. I tracked my lack of errors down to apachesolr_panels which does an explicit test for is_array()!)

The new patch looks good to me, and tests fine. I'm calling this RTBC.

japerry’s picture

Status: Reviewed & tested by the community » Fixed

Heh that docblock was definitely wrong. Fixed!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.