I have installed FacetAPI and SearchAPI and they work fine. However, when I enable "Search facets" the system returns an error:

Notice: Undefined index: field api bundles in facetapi_map_assoc() (line 726 of /var/www/sites/all/modules/facetapi/facetapi.module).

The error disappears the moment I disable Search facets" again.

Notice: both FacetAPI and SearchAPI run the latest version.

Anyone has an idea with how to solve this?

------

EDIT: Appears as if the error concerns each added Search index under Search API. Once I clear all the search indexes, the error is gone. Not sure if this a FacetAPI concern or a SearchAPI concern eventhough the error message relates to the facetapi.module.

Please advise.

Regards,

Nyborg

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

STNyborg’s picture

Issue summary: View changes
wsantell’s picture

Version: 7.x-1.x-dev » 7.x-1.5

Speculating, based on how this happens on my site:

I modified the function at line 725 to print the array if $key isn't a key in $array:

function facetapi_map_assoc(&$array, $name, $key) {
  if (array_key_exists($key,$array)) {
    $array[$key] = drupal_map_assoc($array[$key]);
  } else {
    print "<pre>";
    print_r ($array);
    print "</pre>";
  }
}

I was only getting this error after cron ran, so I ran cron and it spit out:

Array 
(
    [map options] => Array
        (
            [entities] => Array
                (
                    [0] => node
                    [1] => file
                )
        )
)

As you can see, 'field api bundles' is not an index; drupal_map_assoc can't make the associative array because the linear array doesn't exist. My guess is that this is occurring for me due to having recently installed the Apache SOLR Search Attachments module, which indexes files attached to nodes.

I removed the else statement from the code above and implemented this to keep the notice from appearing.

eMuse_be’s picture

Same problem.

Also gives problems with facetapi_pretty_paths.

Related issue: https://www.drupal.org/node/2471563

mausolos’s picture

I made a patch to dispose of this error, though you should note that it doesn't necessarily solve whatever is actually CAUSING the root issue. However, I stand by this since it's generally good practice to test your variables for existence/viability before trying to act on them. Please test.

I built against:
search_api_facetapi 7.x-1.22
facetapi 7.x-1.5+22-dev

eugene.ilyin’s picture

I cannot reproduce this error. Maybe it's already gone. But yes, this checking can be added.

If anybody will face this problem again, let me know, please.

eugene.ilyin’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

frederickjh’s picture

I cleaned up the patch in #4 so it only patches the module and not .htaccess as well. This allows for automated patching of the module.

frederickjh’s picture

FileSize
561 bytes

One more try, cleanup the path on this one.

frederickjh’s picture

FileSize
473 bytes

One more time. I missed one level of the path.

julien.reulos’s picture

I don't think the maintainer included the update of the .htaccess file in his fix, see the corresponding commit (mentioned above): https://git.drupalcode.org/project/facetapi/commit/900bd713