I have had this showstopper bug. I am not sure if this is an entity issue or a core issue.
There are modules which do not populate all elements of entity_load.
I think that this contributes to the fatal error but I am not sure.
I did a print backtrace on the error. The issue for me is that it is not just one module, a few don't define it.
Array
(
[0] => Array
(
[file] => /var/aegir/platforms/7/servers/drupal-7.14/includes/common.inc
[line] => 7633
[function] => entity_get_controller
[args] => Array
(
[0] => user
)
)
[1] => Array
(
[file] => /var/aegir/platforms/7/servers/drupal-7.14/modules/user/user.module
[line] => 287
[function] => entity_load
[args] => Array
(
[0] => user
[1] => Array
(
[0] => 0
)
[2] => Array
(
)
[3] =>
)
)
[2] => Array
(
[file] => /var/aegir/platforms/7/servers/drupal-7.14/modules/user/user.module
[line] => 362
[function] => user_load_multiple
[args] => Array
(
[0] => Array
(
[0] => 0
)
[1] => Array
(
)
[2] =>
)
)
[3] => Array
(
[file] => /usr/share/php/drush/includes/drupal.inc
[line] => 138
[function] => user_load
[args] => Array
(
[0] => 0
)
)
[4] => Array
(
[file] => /usr/share/php/drush/includes/bootstrap.inc
[line] => 945
[function] => drush_drupal_login
[args] => Array
(
[0] => 0
)
)
[5] => Array
(
[file] => /usr/share/php/drush/includes/bootstrap.inc
[line] => 185
[function] => _drush_bootstrap_drupal_login
[args] => Array
(
)
)
[6] => Array
(
[file] => /usr/share/php/drush/includes/bootstrap.inc
[line] => 345
[function] => drush_bootstrap
[args] => Array
(
[0] => 6
[1] => 7
)
)
[7] => Array
(
[file] => /usr/share/php/drush/includes/bootstrap.inc
[line] => 291
[function] => drush_bootstrap_max
[args] => Array
(
)
)
[8] => Array
(
[file] => /usr/share/php/drush/drush.php
[line] => 79
[function] => drush_bootstrap_to_phase
[args] => Array
(
[0] => -2
)
)
[9] => Array
(
[file] => /usr/share/php/drush/drush.php
[line] => 59
[function] => _drush_bootstrap_and_dispatch
[args] => Array
(
)
)
[10] => Array
(
[file] => /usr/share/php/drush/drush.php
[line] => 14
[function] => drush_main
[args] => Array
(
)
)
)
Comments
Comment #1
kevinquillen commentedI am getting this same error, but not sure how to get around it. I currently cannot run Drush because that error comes up each time.
Comment #2
kevinquillen commentedIt keeps tripping on my custom entity, claiming it can't see its controller class. However, dumping entity_get_info() elsewhere shows that it in fact has one. Why then, does this fail?
Comment #3
kevinquillen commentedNow it stops on NodeController.
Just for kicks, I added a ternary to prevent $class from being '' or null:
Which then results (drush cc all) in:
I assume 1560 is a node ID, which would be my frontpage.. This is about as far as I have gotten with this error in 3 hours and really do not know where else to look. I am kind of crippled.
How in the world do you fix this?
Comment #4
socialnicheguru commenteddo you have a short list of modules installed?
Can you list them here?
I had an issue with drupalchat and feedback module. I am sure they are not the only ones though.
I am surprised this has not shown up for others.
PS.
On a side note, PDO errors cripple the system in Drupal 7. Is there anyway around them?
Comment #5
kevinquillen commentedI mean it was fine until I updated these modules on Sunday:
How can you even pin down where the problem is?
Comment #6
socialnicheguru commentedI rewrote with debug information:
Comment #7
kevinquillen commentedIt looks like a Context with a PHP condition that uses arg(1) to run a load with the module loader function and not entity_load.
I have changed the code, but cannot clear the cache still to get rid of this. I truncated the cache* tables and it still persists. Is there a Drush cache or something? I have removed the PHP AND disabled the context.
Comment #8
kevinquillen commentedWow, this was a hard one to clear. Once this is up and stuck in the cache, it was very difficult to remove it. I called drupal_static_reset inside a PHP script, causing a segfault (yep), came back and drush cc all one more time- that time it worked. Thank you for your help.
What is the proper protection to keep this from happening?
Comment #9
socialnicheguru commentedin #7 where did you change the code? did you change each module? could you cut and paste the snippet here?
this might be something that a lot of modules do, not just those two.
Comment #10
kevinquillen commentedIt was a Context PHP condition set by a dev, like a block you put PHP code in. It was checking to see if it was on a particular entity detail page, by loading the object with arg(1) (similar to checking for $node with node_load(arg(1)).
Comment #11
socialnicheguru commenteddo you have a specific line of code where you changed it in context mdoule?
Comment #12
kevinquillen commentedI didn't- it was custom code in that condition that I removed.
Was using entity_class_load(arg(1)) and I replaced it with entity_load('my_entity', arg(1))- which cleared it up, seemingly.
Comment #13
socialnicheguru commentedhmmm, I am wondering if other modules are doing the same thing.
I was using off the shelf modules.
Comment #14
kevinquillen commentedI thought this was a somewhat accepted way of checking if you can load an object on a particular page. I suppose not for custom entities?
Comment #15
kristen polI was getting a similar error when I copied my site over to a new server. After running update.php, it sorted itself out though there were no database updates to run. Weird!
Comment #16
saltednutI am seeing the same error on a different line when I try to useentity_save()orentity_delete()Fatal error: Class name must be a valid object or a string in /drupal-7.14/includes/common.inc on line 7656Here are some examples that will cause the error:
My bad: this was caused by menu callback function conflicts with hook_delete and hook_update.
See: #1694428: U and D in CRUD need working callbacks in Entity JS
Comment #17
kepford commentedI was having the same issue as @Kristen Pol and running drush updb && drush cc all cleared it up.
Comment #18
jlporter commentedI can also confirm this still happens under certain circumstances. The drush updb and cc all afterwards cleared it up.
The only thing that was done prior to fatal wsod, was a feature was enabled that had to use the same field on two content types. This is the only thing we hypothesize that was the underlying problem.
Comment #19
prdctvtxt commentedI experienced this issue today. Solved by stopping memcached, restarting apache, truncating cache tables.
Site comes back; start memcached, restart apache.
Comment #20
kevinquillen commentedThe most common cause I found was with things like Solr and Memcache. If you delete an entity and those caching systems are not updated (through proper API usage, entity_delete etc), attempting to load an entity id that no longer exists causes some nasty problems.
Comment #21
Michsk commentedHere is what happend for me;
Custom block snippet before:
The block that used above was displayed on all pages. The problem with that is that when you visited an 404 OR 403 like
/admin/when not being logged in, or any other strange page. I had custom 404 and 403 pages, something like/woops/404. With above code the$entity_typewould bewoops. Which of course is not right.Correct code
Comment #22
mralexho commentedOne of our developers ran into this issue as well. Although he's running a different version (7.22), this may help -
Like @kepford mentioned, if
drush updbanddrush cc alldoesn't work, try truncating yourcache_*tables first.Comment #23
bfuzze9898 commentedI run into this problem intermittently, usually because I've done something stupud. I can't promise that's not the case in this instance, but something weird is definitely going on and I am able to reproduce it.
Environment:
Drupal 7.28
PHP 5.3.10-1ubuntu3.11
PostgreSQL 9.1.13
It started when I disabled the Devel module, but this seems to happen across many modules.
First, an error kicked off from the termstatus contrib module, user_access() is undefined (warning sign). I wasn't using that module so I moved it and then this error reared its ugly head.
Ran through the regular gambit (truncate the tables, clear the browser cache, even did the drush updb and drush cc all, mentioned above. Nothing worked.
Had to dive into the code to figure out what was going on:
I won't paste the entire backtrace because it's painful, but it was definitely failing to load the user entity info.
common.inc
entity_load >
entity_load_controller >
entity_get_info >
Adding the following test code which seemed to correct the issue (this is core so not a solution).
Was able to login now.
I removed all test code from common.inc and flushed the cache, problem comes back!
The solution I settled on was adding these 2 lines to the top of my custom module which apparently is loaded early enough to catch this issue. Not ideal, but it works.
Maybe my experience will save others some time.
Fun stuff.
Comment #24
bfuzze9898 commentedWord to the wise and not so wise.
I started to notice additional system instabilities with other core and contributed modules with similar entity-info errors. After much deliberation, I found the cause was some custom-module initilization logic written inline instead of inside a hook_init function. When flushing the cache, this logic was calling drupal core functions before all modules were loaded or finished loading, leading to a variety of unexpected behavior (particularly with modules loaded late like wysiwyg).
Hope this helps someone.
Comment #25
ahsanra commentedI managed to solve this problem with few steps below.
First step: go to common.inc in includes folder
find the function "function entity_get_info($entity_type = NULL)"
change the line if ($cache = cache_get("entity_info:$langcode")) to if (false && $cache = cache_get("entity_info:$langcode"))
Now this cache is disabled.
next step:
Add the following 3 lines in the else statement above the "module_invoke_all function", so that the whole chunk becomes like below
if (empty($entity_info)) {
if (false && $cache = cache_get("entity_info:$langcode")) {
$entity_info = $cache->data;
}
else {
var_dump(module_list()); // Add this new line
var_dump(module_implements('entity_info')); // Add this new line
var_dump(function_exists('user_entity_info'));// Add this new line
$entity_info = module_invoke_all('entity_info');
Now you will be able to load the page and log in to the admin panel.
Login and Clear the Cache.
You are good to go. It should work like it did for me.
Once you have done the above, revert all the changes.
Thanks,
Comment #26
steveoliver commentedFor me this was due to PHP version differences (i.e. between 5.3.10 and 5.3.29) where (string) $object (on an object implementing no __toString() method) generated the "Recoverable fatal error" running 5.3.10 and no error running 5.3.29. Keeping such an object from being cast as string was the bug to fix in my custom code. Similar casts of objects to string with certain version of PHP (I don't know which) may be the cause of the different cases above.
Comment #27
alemadleiFor me, this fixed it, by doing it on mysql
I added code on a module file at the wrong location (it executed as part of the file and then I called die.
After clearing chace from the DB it worked for me.
Comment #28
alemadleiFor me, this fixed it, by doing it on mysql
I added code on a module file at the wrong location (it executed as part of the file and then I called die.
After clearing chace from the DB it worked for me.
Comment #29
socialnicheguru commentedin my original issue, user_load was being passed an array for uid.
https://api.drupal.org/api/drupal/modules%21user%21user.module/function/... says that user_load takes an integer only in D7.
Maybe it was a cached value that cleared up after a cache clear?
Comment #30
duppy.ocio commented#27 worked for me.
Thank you!
Comment #31
emmonsaz commentedI had to run updatedb, clear Drupal cache, and then clear memcache to fix this. Thanks @prdctvtxt
Comment #32
dinesh_b commentedI cleared table cache , memcache cache and solr too but still error not resolved .
It comes when I make solr search in search result page. This is what I get in logs
Error: Class name must be a valid object or a string in entity_get_controller() (line 7998
Someone please help me.
Comment #33
dinesh_b commentedJust created a new Solr instance and it worked.
Comment #34
rsorokine commentedThis one should work:
Comment #35
stateoftheheart commentedThat worked for me. Thanks!
Comment #36
donavanwilliams commentedThanks @rosrokine
#34 worked for me.
Comment #37
yelvington commentedJust leaving this for others who run into this problem:
drush @sitename.env --fire-bazooka --strict=0
Seriously. This forces an aggressive rebuild of the registry (multiple passes, multiple cache clears) and pretty much clears out all the cockroaches. As documented, you should back up the DB first.
Comment #38
dahousecat commentedI tried all of the above but nothing worked. Looking at the backtrace the error for me originated from menu.inc.
I put
return NULL;as the first line ofmenu_local_actions()andmenu_local_tabs().I then did a registry rebuild (drush rr) and cleared the cache (drush cc all), and then removed those lines again.
After that is was all fine... hope this might help someone else.
Comment #39
liam morlandThe attached patch fixes this issue. There is also a core-level fix proposed in #1982810: Core entity_get_controller gets a NULL controller class.
Comment #40
nitin.k commentedAwesome #34.
Comment #41
maxplus commentedHi,
#34 worked for me, thanks
Comment #42
cubeinspire commentedIf you are facing a similar problem I would suggest to backtrace the error by temporarily hacking the common.inc file with this:
Module devel required of course. That is how I've found the code that was giving problem and corrected the error.
It was simply due to a entity_load on a null entity type that happened on a particular situation.
Comment #43
andrewtf commentedI can vouch for #34, too. Thanks for that! I thought I was going to be in for a long day... (Might still be, it's early.)
Comment #44
hfvd commentedI installed the module "modules_weight" and positioned my custom module as last (100). Saved, cleared the cache, and gone was the error. My custom module uses cache_clear_all() so probably that was the problem.
Comment #45
Gnanasampandan Velmurgan commentedHI,
#39 This patch worked for me. thanks
Comment #46
alauddin commented#39 patch worked!
Thanks.
Comment #47
liam morlandSince it is working for you, you could mark it "reviewed and tested by community".
Comment #48
jomarocas commentedI apply the patch and tested an working good for me, but need apply the following patch for working https://www.drupal.org/files/issues/drupal-entity_get_controller_null_co... in drupal core
updated the issue for tested, but without this patch in core, probably dont working
Comment #49
mglamanThis should probably have tests added to it, too, correct?
Comment #50
g33kg1rl commented#34 and the patch from #48 cleared up the issue for me. This was preventing me from being able to migrate and upgrade websites on Aegir.
Comment #51
wajdigharbi commented#34 the patch return the following error:
"error: corrupt patch at line 44"
Comment #52
marcoka commented#34 worked for me with php 7.2.1
btw #34 is not a patch, just some drush commands.
Comment #53
zakir.gori commentedFollowing works for me
UPDATE system SET status='0' WHERE name='module_name';
DELETE FROM cache_bootstrap WHERE cid='system_list';
TRUNCATE TABLE cache;
TRUNCATE TABLE cache_admin_menu;
TRUNCATE TABLE cache_block;
TRUNCATE TABLE cache_bootstrap;
TRUNCATE TABLE cache_features;
TRUNCATE TABLE cache_field;
TRUNCATE TABLE cache_filter;
TRUNCATE TABLE cache_form;
TRUNCATE TABLE cache_image;
TRUNCATE TABLE cache_libraries;
TRUNCATE TABLE cache_menu;
TRUNCATE TABLE cache_page;
TRUNCATE TABLE cache_path;
TRUNCATE TABLE cache_rules;
TRUNCATE TABLE cache_token;
TRUNCATE TABLE cache_update;
TRUNCATE TABLE cache_views;
TRUNCATE TABLE cache_views_data;
Thanks
Comment #54
ashique12009 commented#28 works for me, thank you.
Comment #55
altagrade commentedHave put the long array between the code tags as otherwise it's impossible to read.
Comment #58
vladimirausUpdated to MR as patch was not applying because of comment.
Comment #59
joseph.olstadThis suggested change looks like a reasonable improvement to me.
Comment #60
joseph.olstad#34 has an extra comment update which I think is important. The merge request does not have that.
I'd say go with #34 for the win