After updating to Entity 1.0-beta9 and Search API 1.0-beta10, I get WSOD's on the majority of my pages. The WSOD is most consistent when I try to clear the cache. I have tried running update.php, re-saving the facets, etc., and I can't seem to get things to work.

PHP Fatal error: Call to a member function entityWrapper() on a non-object in /path/to/search_api/contrib/search_api_facets/search_api_facets.module on line 922

Comments

drunken monkey’s picture

You seem to not have run update.php right after updating (did you maybe first try to clear the cache?), or something went wrong with the update.

cache_clear_all('entity_info:', 'cache', TRUE);

This (i.e., the update code) should fix the issue. I had the same error before I wrote the update function.
The cause is the following:
- The stale entity_info cache data causes indexes to use the wrong controller class.
- The wrong controller class can't load indexes by name.
- Facets load their index by name.
- And the really bad thing: The facets' cache is rebuilt before the entity info is.
Maybe with this information you can find some other fix if the above doesn't help.

a1russell’s picture

Actually, I did run update.php right after updating. I've finally found what I think is triggering it. Things work fine until I try to recreate my features containing the index and the facets. The diffs of the recreation look something like:

In my_feature.features.inc:

 function my_feature_default_search_api_index() {
   $items = array();
-  $items['node_index'] = entity_import('search_api_index', '{
+  $items['2'] = entity_import('search_api_index', '{
     "name" : "Node index",
     "machine_name" : "node_index",
     "description" : "Search index for indexing node data.",

And in my_other_feature.info:

-features[search_api_facet][] = "node_index_field_foo"
-features[search_api_facet][] = "node_index_field_bar"
+features[search_api_facet][] = "1"
+features[search_api_facet][] = "2"

After I put these recreated features in place, the machine_name of my node index seems to change from node_index to 2, and everything goes down the toilet from there.

pfrenssen’s picture

I'm having the same problem. I have to disable Features to be able to use the new versions of Search API and Entity API.

drunken monkey’s picture

Seems to be caused by/related to #1193862: Rules are exported by Features with their numeric IDs instead of machine names. Does this still happen with the latest Entity API dev version (where this should now be fixed)?

a1russell’s picture

Status: Closed (fixed) » Active

Ah, who would have known to check the Rules issue tracker for an issue encountered in Search API? Haha. That was it, though... Thanks.

*Edit: Okay, the issue was in the Entity tracker, but still...the title was misleading. ;)

a1russell’s picture

Status: Active » Fixed
jfmyself’s picture

I have the same problem... where have I to put this code in my update.php file???

cache_clear_all('entity_info:', 'cache', TRUE);

Should I replace this?
if (db_table_exists('cache_update')) {
cache_clear_all('*', 'cache_update', TRUE);
}

drunken monkey’s picture

No, never change code in Drupal core files!
This problem should disappear when updating to the newest dev version of the Entity API, and then running update.php normally. (And then recreating the features.)

jfmyself’s picture

should I update my Drupal core (7.0) to 7.2??? Could that be a reason of WSoD too???

a1russell’s picture

Jfmyself, please at least try the solution discussed in this thread before asking about other possible causes of the problem. A bug report is not a place to ask for general support. That said, seeing as how Drupal 7.1 (and 7.2) include security fixes from 7.0, you should update regardless of whether it is the cause of any WSOD.

jfmyself’s picture

Ok thanks! Sorry I didn't know... :S

Status: Fixed » Closed (fixed)

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

Status: Active » Closed (fixed)