When trying to access a View page with a search sort block on it, after updating to 7.x-1.x-dev I got:

Fatal error: Cannot use object of type stdClass as array in ..../search_api_sorts/search_api_sorts.module on line 151

<?php
function search_api_sorts_search_sorts($index_id, $enabled = 1, $reset = FALSE) {
.....
    $index = search_api_index_load($index_id);
    while ($row = $query->fetch()) {
      // Check that this field exists in index.
      if (!empty($index->options['fields'][$row['field']])) {
?>

I am working on a Commerce Kickstart site trying to upgrade to the current version from rc2. It's pretty difficult as something in the search index setup doesn't want to show the sort block. I tried changing the module back to the older version and I still got this fatal error. Is this related to the recent updates on search_api and search_api_db ?

Wish it were easier to diagnose this monster - I tried updating the search_api modules to their new versions just released via drunken_monkey and same result. Also tried changing it to $index = search_api_index_load($index_id, true); to reset the cache on that call.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

HongPong’s picture

Issue summary: View changes
HongPong’s picture

I was able to get out of the Fatal Error situation by restoring back to version 7.x-1.4 .

samuel.mortenson’s picture

I also got this after an update from an older dev version to the most recent version of dev, ended up reverting to fix the error.

Finn Lewis’s picture

As far as I can tell, this is because the line

if (!empty($index->options['fields'][$row['field']])) {

shoule be

if (!empty($index->options['fields'][$row->field])) {

Patch attached against current dev version.

alanmackenzie’s picture

Status: Active » Reviewed & tested by the community

Patch in #4 works as described.

Anonymous’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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