OK, this is a bit weird and I'm not entirely sure of how to fix it, so I'll try to be as specific as I can.
1) Create a module that defines a new entity and hooks into Field API/Field UI.
2) Create a bundle (or have it pre-defined by the module).
3) Attach a field instance to that bundle.
4) Disable the module. (Or possibly just delete that bundle; I've not tested yet.)
5) Go visit the "Manage fields" page for any other bundle. You'll get a notice on an undefined index in common.inc line 6320 of common.inc, which is the end of entity_get_info(), followed by a couple of foreach() errors.
As near as I can tell, the problem is that the entity system, or maybe fields really, is loading data about all field instances when viewing any individual bundle's field UI page. If any of those instances refer to bundles that no longer exist, it can't handle that and chokes as above.
To me the solution sounds like making Field API smarter so that it does not try to load field instances it doesn't need, as that is wasteful and in this case buggy. I don't know enough about the guts of Field API to know the correct way to do that, though. I defer to the Field API gurus on that one.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | field_disabled_entity_type-668386-6.patch | 4.74 KB | yched |
Comments
Comment #1
yched commented_field_info_collate_fields() does loop on every field instance, including the ones on unavailable entity types or bundles currently.
Ugh. Handling unavailable field types, widgets or formatters we did already.
Handling unavailable entity types is a bliss new to D7.
Not fully sure of the best place to handle this right now, but we need to adress that. Bumping to critical.
Comment #2
figover commentedHi Crell,yched,
I am not able to define a new entity through new module. Can you please show the code of that module?
I am eager to work in Field API.
Comment #3
yched commentedMarked #679936: Remnants of comment information when module is disabled as duplicate.
Comment #4
joachim commentedQuickest way to see this bug is to disable comment module, as in the duplicate issue.
Comment #5
Crell commentedOh is that why I'm getting a ton of notices now on a brand new fresh install. Lovely. That makes this even more critical.
Comment #6
yched commentedThis should do the trick:
- make sure entity_get_info($entity_type) doesn't raise warnings if $entity_type is unknown
- make sure field_read_fields() only returns instances on known entity types (except if 'include_inactive' param is explicitly set)
With a test - not bot tonight it seems, but I checked locally that the test fails on HEAD and passes with the patch.
Comment #7
yched commentedSide note - caught this when working on the patch : #700194: Optimize field_modules_disabled()
Comment #8
catchJust ran into this on a custom module, you can end up with hundreds of warnings without the patch applied, all clear with it. Solution looks good.
Comment #9
webchickI really don't like committing patches like this without testbot to back me up, but OTOH I hate piles-o-notices, too. ;) And it comes with tests, so that's cool.
Committed to HEAD.