I am getting this error only when Bootstrap is set as my theme, 4 other themes work just fine. All pages get the HTTP 500 error, including my login page.

PHP Fatal error: Call to a member function sort() on null in /sites/all/modules/search_api/contrib/search_api_views/includes/query.inc on line 138

Here is that section of code.

**
   * Adds a sort to the query.
   *
   * @param string $selector
   *   The field to sort on. All indexed fields of the index are valid values.
   *   In addition, these special fields may be used:
   *   - search_api_relevance: sort by relevance;
   *   - search_api_id: sort by item id;
   *   - search_api_random: random sort (available only if the server supports
   *     the "search_api_random_sort" feature).
   * @param string $order
   *   The order to sort items in - either 'ASC' or 'DESC'. Defaults to 'ASC'.
   */
  public function add_selector_orderby($selector, $order = 'ASC') {
    $this->query->sort($selector, $order);
  }

Why only the Bootstrap theme? I have cleared cache via Drupal and manually deleted the cache tables, so not sure what it could be? A search under this module and on bootstrap theme sites, I could not find anything pointing me somewhere.

Thanks for any input.

Comments

tyler-durden created an issue. See original summary.

drunken monkey’s picture

Category: Support request » Bug report
Status: Active » Needs review
StatusFileSize
new584 bytes

Why only the Bootstrap theme?

I have no idea, sorry. I haven't worked with that theme before, but how any theme should influence that seems pretty dubious.
The immediate problem, though, however it was caused, seems to be that there was no search query object set on the plugin when it was initialized. And in this one method we apparently forgot to add a check for that eventuality.
Please try out the attached patch, which adds that check. If nothing else, it should at least give you a more useful error message.

drunken monkey’s picture

Component: General code » Views integration
tyler-durden’s picture

Sweet, that cleared the error. Thanks!

tyler-durden’s picture

I only had 90 seconds this morning to apply the patch and do a quick test.

Looking into this further, I think it was working before I upgraded Solr from 1.4 to 5.x, along with quite a few Search API updates. I was using another template for awhile and never looked at it since those changes, through the Bootstrap template. I used 4 or 5 other templates and they all worked, so that's a head scratcher.

  • drunken monkey committed d41c745 on 7.x-1.x
    Issue #2875793 by drunken monkey: Fixed buggy error handling in Views.
    
drunken monkey’s picture

Status: Needs review » Fixed

Thanks for the feedback!
If it removes the error, that's at least definitely good, so I just committed that patch now.

I don't quite understand your last paragraph. Is this now working, or do you have more problems you'd like to discuss? I.e., should this issue go to "Fixed" or back to "Active"? (I now chose the former, as default, but feel free to move back to "Active" and explain your current problem further.)

tyler-durden’s picture

It should go to fixed, the error was new to me after updating those things, but I don't know what surgically it was because I updated a lot of things at once.

Thanks!

Status: Fixed » Closed (fixed)

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