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 patch in #943772 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
implementshook_field_info()
to define a field typefoo_type
.foo.module
depends onfoo_field.module
.- When a user installs
foo.module
,foo_install()
callsfield_create_field(array('field_name' => 'foo', 'field_type' => 'foo_type'))
. - When the user uninstalls
foo.module
,foo_uninstall()
callsfield_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
.
@todo: For an already-installed module which has violated the "don't do that" rule above, describe how to manually remove data so that the module can be uninstalled.
- Experimental module that provides an "orphaned fields" report:
- Related issues:
-
#943772: field_delete_field() and others fail for inactive fields
-
#1115510: Entity providing modules must call field_attach_delete_bundle() in hook_uninstall()
-
#895014: All fields of a node type are lost on module disable
-
#1264728: Refresh field 'active' state in module_enable() / _disable()
Comments
How to manually fix this problem for an already-installed module
As you uninstall your module you will probably see some some error messages thrown by the text module, you can safely ignore these.
Apparently something has
Apparently something has changed since you left your comment. Following your instructions worked to allow me to disable and uninstall a module that defined one of my fields, but doing so did not remove the existing fields, or delete the custom field tables.