What could cause the site to suddenly start dying with the "Call to undefined function entity_get_info()" error? So I was working away at trying to solve the problem I asked about in How can I combine the fields of two field collections in my theme? when suddenly Drupal died with this error message:


  Fatal error: Call to undefined function entity_get_info() in /path/to/drupal/sites/all/modules/entity/includes/entity.inc on line 57


This is the call stack.



Now since it seems to die when working with the field collection module, and I was working with that field, it is obvious that something I did caused the entire site to crash, but how, and how can I recover from it?  I can't clear cache to try to see if that fixes anything because drush throws the same error and I can't access the cache clear on the site itself obviously.

What I was doing

I was working on the theme_preprocess_field() function and had something like this:

&lt;?php
function enviroscope_preprocess_field(&amp;$variables) {
    $roles = array();
    if ($variables['field_name_css'] == 'field-doc-staff-contrib-fc') {
        foreach ($variables['items'] as $item) {
            $role = array_values($item['entity']['field_collection_item'])[0]['field_fc_doc_iges_role'][0]['#markup'];
            $user = array_values($item['entity']['field_collection_item'])[0]['field_fc_doc_iges_user'];
            $toreplace = $user['#object']-&gt;field_fc_doc_iges_user['und'][0]['entity']-&gt;name;
            $replacewith = $user['#object']-&gt;field_fc_doc_iges_user['und'][0]['entity']-&gt;field_user_family_name['en'][0]['#safe_value']
            $roles[$role][] = $item;
        }
    }
    kpr($roles);
} 


I started adding some scaffolding for the next step, which was to be examining the field-doc-other-contrib-fc field collection field.

I meant to modify the code after kpr($roles); to read as follows:

    kpr($roles);
    variable_set('roles_to_pass', $roles);
} else if ($variables['field_name_css'] == 'field-doc-other-contrib-fc') {
    $roles = variable_get('roles_to_pass', array());
    // sort and mix these together
    variable_del('roles_to_pass');
}


My best guess about what possibly could have happened is that I accidentally wrote else if ($variables['field_name_css'] = 'field-doc-other-contrib-fc') { (note the = instead of the ==) which would have reset the field_name_css on every field except the first field collection field I was working on.  Would this explain the entire site going down in the way it has?  How can I recover from it?

In the morning if there is no answer I'll try deleting all rows from the various cache_* tables directly in the database, but for now I need to hit the hay.

Update

Clearing out the cache tables and commenting out my entire template.php had no effect.  Is my entire install hosed?
You have a classed FieldCollectionItem object in your variables table. Drupal 7 isn't designed to handle this.

When you use variable_set() to save an object to the variables table, the object must first be converted into a string using serialize(). Later, it will have to figure out how to convert that string back into a FieldCollectionItem object, and it will call the __wakeup magic method on the class to help it figure out how to do that. It turns out that __wakeup method requires code that isn't bootstrapped yet at the time that Drupal reads from the variables table, so you get the fatal error.

But you're not hosed. It looks you probably saved the object in the 'roles_to_pass' variable. If you can edit your database, try removing that record from the {variable} table, then clear your cache tables.