It appears that sometimes module_invoke_all('entity_property_info')
is being called before all of the "modules/$module.info"
files are included. Sometimes this bad list of implementations gets saved to the cache by module_implements()
.
In my case we are using EntityMetadataWrapper on nodes on every page. This bad cache entry is causing all future page requests to fatal error (since as far as Entity module is concerned, the node entity type doesn't exist). The only solution is to clear the 'module_implements' entry from 'cache_bootstrap' and wait a few days until the error happens again.
I realize that the current release is RC3, so our first step will be to upgrade.
Comment | File | Size | Author |
---|---|---|---|
#12 | modules.txt | 9.14 KB | benjy |
#3 | 1819790_include_implementations_before_calling_3.patch | 517 bytes | dalin |
Comments
Comment #1
fagoQuestion is when the wrong cache entry is written. That might be the result from some wrong use. We need to track the source down and see what's wrong there.
Comment #2
dalinI've hacked module_implements() to add some extra logging and a backtrace when the bad cache entry is written. I'll keep you updated.
Comment #3
dalinTurned out to be very simple: module_invoke_all('entity_property_info') was being called when entity.info.inc was not included.
Comment #4
dalinAlternatively, since there's no guarantee that module_invoke_all('entity_property_info') will not be called from another module, it might be an idea to just move all functions (not objects) from entity.info.inc to entity.module.
Comment #5
dalinAnd, for reference, here's the backtrace that helped find the problem:
Comment #6
bulldozer2003I've unfortunately experienced this bizarre problem as well. Searching for the error yields many people clueless as to the cause. I was for a long time as well. Usually they have it fix itself, likely when the module implementation cache is reset.
My manual fix was to run module_implements('entity_property_info', FALSE, TRUE); which resets the implementation cache.
I am using Entity 7.x-1.0, I will have to test against the latest dev. I can produce this every time I clear the cache on my development site.
Comment #7
dalinI think this still needs to be "needs review" since there's a patch that fixes the issue, but people need to try it out, verify that it works, and verify that it is the best way to fix the problem.
Comment #8
bulldozer2003The patch in #3 doesn't solve my problem. After clearing caches, entity still disappears from the output of module_implements('entity_property_info');
Whoops, hadn't refreshed since I last posted. But I think going back to active is valid since the patch didn't resolve. I would need to comment again to move it to needs work.
Comment #9
dalinIn that case the proper status would be "needs work":
https://drupal.org/node/156119
Comment #10
bulldozer2003I take that back. This does alleviate my problems with exceptions. I'm still not sure if the other errors I am having are entity related or not but they're not caused by this module.
Comment #11
fagoYeah, but this should be auto-loaded thanks to our hook_hook_info() entry. Maybe somehow that ends up broken in your case? I do not see a problem with our implemenation here?
Comment #12
benjy CreditAttribution: benjy commentedThis is still definitely an issue. I had it today and the patch attached would fix the issue but It's not the solution to the root cause.
Basically entity.info.inc never gets included because hook_hook_info() never fires. Another solution that also worked for me was changing the weight in the database. I could reliably changed entity.module weight to -1 the problem would be fixed, back to 0 and it's broken again. I thought it would be a conflict with the system module but changing the system module weight didn't affect the issue.
I've attached a list of enabled modules from my site in case anyone wants to try and track this down further.
One symptom of this bug is that entity_metadata_wrapper doesn't' work at all for core entity types such as node.
Comment #13
benjy CreditAttribution: benjy commentedOK, I tracked the core of this problem down.
define('SOME_LINK', url('sites/default/themes/custom_theme/images/pin.png', array('absolute' => TRUE)));
Someone had put a call to "url" outside of any functions, just at the top of the module file. This could have been any function that causes the module_implements cache to be loaded.
I tracked it down with this little snippet.
To run it, save as script.php and use drush,
drush scr script.php
I think this should probably be closed (Works as designed)?
Comment #14
steinmb CreditAttribution: steinmb as a volunteer commentedI also experienced. Posted my findings in #2953345: entity.info.inc not loaded at correct time - I also went ahead and changed that issue one into a support issue. Perhaps some of the maintainers could shed some light on this issue, now that we know what cause it. I think this might be a weakness in this module. It was the only module as far as I could see failing. We could go ahead and close this issue but on the other hand, there is some good in there work done by @benjy trying to track down the problem. One a larger site, it is not easy to track down.
Comment #15
caschbre CreditAttribution: caschbre commentedThe patch provided appears to be a duplicate to the patch in #1819790: module_implement('entity_property_info') does not return Enity module's implementations for core entity types;
Comment #16
david.hughesI ran into a similar problem to this, found this issue with a patch that at request-time recovers the entity_property_info if the cached value was set to an empty array for whatever reason. Patch in #2 of https://www.drupal.org/project/entity/issues/2629982 fixes this.