When I try to open page /admin/config/search/redirect, it returns error:
Fatal error: Class name must be a valid object or a string in xxx/includes/common.inc on line 7749

Comments

drupalfan79’s picture

After clear cache, there is no this error

myhemant’s picture

Thanks, its start working after clear cache.

Dave Reid’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

therobyouknow’s picture

Clear cache worked for me too - thanks:

drush cc all

Though I do now get (a non fatal) error:

array_keys() expects parameter 1 to be array, null given common.inc:7029

when I issue drush cc all

dvandusen’s picture

Issue summary: View changes

Class name must be a valid object or a string in drupal7/includes/common.inc --- bug generally affects many areas of drupal

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. Please fix 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

dvandusen’s picture

Status: Closed (fixed) » Needs review
Issue tags: +Class name must be a valid object or a string in drupal7/includes/common.inc --- bug generally affects many areas of drupal

Bump this one to not yet fixed. The real issue is in Common.inc.

Pere Orga’s picture

Status: Needs review » Postponed (maintainer needs more info)

It's not clear if that is a Redirect bug.

Pere Orga’s picture

Priority: Critical » Normal
Pere Orga’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)
Rosamunda’s picture

Maybe it's not a redirect issue. I have not used this module, but after rebuilding permissions, I've got the same error qhen a user tries to access her profile.
Clearing cache solves the issue. But... is it going to appear again randomly???!!!