Needs work
Project:
Facebook Autopost
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Reporter:
Created:
25 Oct 2013 at 18:46 UTC
Updated:
7 Apr 2015 at 06:53 UTC
Jump to comment: Most recent
drush en -y fb_autopost_types, fb_autopost_entity
The following extensions will be enabled: fb_autopost_types, fb_autopost_entity
Do you really want to continue? (y/n): y
PHP Fatal error: Class name must be a valid object or a string in /includes/common.inc on line 7855
Fatal error: Class name must be a valid object or a string in /common.inc on line 7855
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Class name must be a valid object or a string in
includes/common.inc, line 7855
When I don't get the error if I do
drush en -y fb_autopost_entity
then
drush en -y fb_autopost_types
Comments
Comment #1
e0ipsoThank you for taking the time to file this issue, I'll look into it as soon as I can.
Comment #2
dvandusen commentedThis 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
Comment #3
3eidoz commentedFatal error: Class name must be a valid object or a string in /includes/common.inc on line 7937
please help
Comment #4
e0ipsoRunning registry rebuild should take care of that.
Comment #5
3eidoz commentedplease explain
this error appeared after updating to V 7.36