I cannot uninstall the field collection module cleanly (uninstall from Drupal, without using db sql query) even after removing all content types with field collection field defined. This is related to: #943772: field_delete_field() and others fail for inactive fields
Current proposed solutions - (as suggested in #943772: field_delete_field() and others fail for inactive fields):
When there is field data in place, there is a de-facto dependency of the field system as a whole on field type modules - if that module is disabled, it is has no idea what to do with the data until the module is re-enabled again (and other actions while the module is disabled, like deleting bundles or instances can complicate this too).
The current patch uses hook_system_info_alter() to make this dependency explicit - i.e. by making those field type modules required in the UI, with an explanatory note.
With the proposed solution, a module which both defines and implements a field type can not delete its fields on uninstall. Therefore, the solution is "Don't do that." Instead, the field type should be defined in a helper module which the implementation module depends on.
For example:foo_field.module implements hook_field_info() to define a field type foo_type.
foo.module depends on foo_field.module.
When a user installs foo.module, foo_install() calls field_create_field(array('field_name' => 'foo', 'field_type' => 'foo_type')).
When the user uninstalls foo.module, foo_uninstall() calls field_delete_field('foo'), and its fields are marked for deletion.
The field values get purged on subsequent cron runs.
After the purge is completed, the user can uninstall foo_field.module.
Comments
Comment #1
Refineo CreditAttribution: Refineo commentedAs a temporary solution I run sql query:
DELETE FROM `field_config` WHERE `field_config`.`deleted` = 1;
(#943772: field_delete_field() and others fail for inactive fields)
Comment #2
mototribe CreditAttribution: mototribe commentedthat worked great for me - thanks!!!
Comment #3
Refineo CreditAttribution: Refineo commented@mototribe, I am glad this helped you.
I think, I will close this issue as the long term solution will come from the Drupal core fix in #943772: field_delete_field() and others fail for inactive fields.
Comment #4
decibel.places CreditAttribution: decibel.places commentedRunning Cron took care of this for me, on fields used by the Brightcove module, not the Field Collection module; presumably the cron hook processes fields marked for deletion.
Comment #5
dwalker51 CreditAttribution: dwalker51 commentedThe sql in #1 did it for me, after running I could drush dis field_collection. thanks
Comment #6
g76 CreditAttribution: g76 commentedyep #1, thanks so much!
Comment #7
truyenle CreditAttribution: truyenle commented#1 work for me too.
Comment #8
valderama CreditAttribution: valderama commentedIn addition to the field_config table you should also cleanup field_config_instance table and also delete the field_deleted_data and field_deleted_revision table(s).
Running cron and hope that field_purge_batch takes care of deletion did not work in my case. I have entity_translation enabled - maybe that disturbs?
Comment #9
knowledges33ker CreditAttribution: knowledges33ker commentedThe query in #1 worked for me as well. Prior to running this we would get an error message any time we tried to delete a field and also errors when running cron.
Thanks @Refineo for the lead!!
Comment #10
ilgriso CreditAttribution: ilgriso commented#1 still needed, thanks so much!
Comment #11
kscheirer#1 worked for me as well - none of the linked issues ever came to a resolution unfortunately. This issue ranks very highly in a google search for "drupal fields pending deletion", so it's become the solution most people use. Perhaps we could document this somewhere a little nicer, and get out of individual module queues?
Comment #12
Bowevil CreditAttribution: Bowevil commented#1 worked for me. I was having issues with addressfield and I could not uninstall that module. +1 karma to Refineo
Comment #13
kopeboy CreditAttribution: kopeboy commented#1 I got this: #1146 - Table 'myDatabaseXXX.field_config' doesn't exist
???
Comment #14
giupenni CreditAttribution: giupenni commented#1 works for me...thank you!!!
Comment #15
iphan CreditAttribution: iphan commented#1 did not work for me. "select * from field_config where deleted=1;" returned an empty set. Same for field_config_instance. I have no table that start with 'field_deleted...'
Uninstall field collection still fails with Required by: Drupal (Field type(s) in use - see Field list). The Field list shows nothing related to field collection.
This fixed it: https://www.drupal.org/node/1867134#comment-8574053