I installed a module in drupal called Views Media Browser, that is when I first noticed the issue.

I properly uninstalled the module (unchecked it, uninstalled it, then removed the folder from my sites/all/modules folder). Now when I go to any article content I've created I am welcomed to the above mentioned error.

I checked the file and the location of it mentioned in the error

 * Get the entity controller class for an entity type.
function entity_get_controller($entity_type) {
  $controllers = &drupal_static(__FUNCTION__, array());
  if (!isset($controllers[$entity_type])) {
    $type_info = entity_get_info($entity_type);
    $class = $type_info['controller class'];
    $controllers[$entity_type] = new $class($entity_type);
  return $controllers[$entity_type];

I even compared it to a vanilla version of Drupal and the files are the same.

I noticed that it does not occur with basic pages or any other content type I have. I would prefer not to have to restart the site, so if there is a way to correct this fatal error I would appreciate it.

  • The module doesn't define any entity. Probably the entity is indirectly created as result of its integration with other modules. Why the reference to that entity is not removed is a mystery.
    – apaderno
    Jan 20 '13 at 23:19
  • Although the uninstall should have done it, have you cleared all caches, particularly class registry cache? Admin > Performance > Clear all caches might help.. just in case some class path is left in the cache there. Jan 21 '13 at 3:04
  • 1
    I was never able to solve the problem, but I simply recreated the content type and the problem wasnt there anymore.
    – amiller
    Jan 24 '13 at 17:19

I had a similar issue today (same error message) and I just solved it. It concerns my personal case, but if the description can help anyone : the problem was the fact that I had created a few items with a content type that I deleted since. So these non published items had an invalid class, because the content type was not existing anymore. I found these 3 items in the list of content with a blank space instead of the content type name. Deleting these 3 items, and then extracting/importing the database again to the customer made it work.

The stange thing is that my version of the site was still working since I deleted the content type, so I couldn't understand why suddenly this problem when migrating the site.


This issue has been raised and closed (without repair) a huge number of times (more than 50 that I can see). It is, admittedly, a tough one to find. I have entered the issue. I have tracked down the actual cause, but the intricacies of the cache are a bit beyond me.

Clearing the cache could help here. Sadly, you can't always get there, largely because drush cc will also blow up when this error is occurring. So will anything having to do with accessing a user (in my case). . Requiring a user to clear the cache every time this occurs is improper by its nature - you can't have a user do a workaround as a normal course of business.

This is the tip of the iceberg on this problem. (the PHP Fatal error: Class name must be a valid object or a string in /includes/common.inc on line 7522).

[[[[in 7.28, at line 7855, 6 = ]]]]

$class = $type_info['controller class']; $controllers[$entity_type] = new $class($entity_type);

The symptom appears because the search for the element ['controller class'] is presumed to be successful. It is not, and no secondary message (such as in a try / catch or an actual test here) is generated.

The issue stems from, for whatever reason, not being able to obtain a $class value from the $type_info array by executing module_invoke_all('entity_info'). Certainly a call time pass by reference could do it, but that would normally be caught. The actual problem is in /includes/common.inc at 7644.

  if (empty($entity_info)) {
    if ($cache = cache_get("entity_info:$langcode")) {
      $entity_info = $cache->data;
    else {
      $entity_info = module_invoke_all('entity_info');
      // Merge in default values.
      foreach ($entity_info as $name => $data) {
        $entity_info[$name] += array(
          'fieldable' => FALSE,
          'controller class' => 'DrupalDefaultEntityController',
          'static cache' => TRUE,
          'field cache' => TRUE,
          'load hook' => $name . '_load',
          'bundles' => array(),
          'view modes' => array(),
          'entity keys' => array(),
          'translation' => array(),
        $entity_info[$name]['entity keys'] += array(
          'revision' => '',
          'bundle' => '',
        foreach ($entity_info[$name]['view modes'] as $view_mode => $view_mode_info) {
          $entity_info[$name]['view modes'][$view_mode] += array(
            'custom settings' => FALSE,
        // If no bundle key is provided, assume a single bundle, named after
        // the entity type.
        if (empty($entity_info[$name]['entity keys']['bundle']) && empty($entity_info[$name]['bundles'])) {
          $entity_info[$name]['bundles'] = array($name => array('label' => $entity_info[$name]['label']));
        // Prepare entity schema fields SQL info for
        // DrupalEntityControllerInterface::buildQuery().
        if (isset($entity_info[$name]['base table'])) {
          $entity_info[$name]['schema_fields_sql']['base table'] = drupal_schema_fields_sql($entity_info[$name]['base table']);
          if (isset($entity_info[$name]['revision table'])) {
            $entity_info[$name]['schema_fields_sql']['revision table'] = drupal_schema_fields_sql($entity_info[$name]['revision table']);
      // Let other modules alter the entity info.
      drupal_alter('entity_info', $entity_info);
      cache_set("entity_info:$langcode", $entity_info);

Notice that if the condition is true in the if at

if ($cache = cache_get("entity_info:$langcode")) { $entity_info = $cache->data; }

then the module_invoke_all('entity_info') is never executed. It just happens that the condition is always met after some other processing is done to create the cache. That means that there is no way to get the entity_info set up --- in my case there was no way to obtain the 'user' entity info, causing the original error above. I made the 'else' one level higher (took out the 'else {}') for testing, and everything worked as it should to clear the error.

I believe that the real bug is that the checking of cache is less than adequate, and that a check on the existence of the entity_info about the specific entity being searched for is needed. In fact, it may be justifiable to also search for the element ['controller class'] for that entity in the entity_info stored in cache. D

  • If you think the same answer fits many questions, consider if flagging questions as duplicates wouldn't be more appropriate.
    – Mołot
    May 10 '14 at 21:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.