In a custom module, I'm creating a new field and instance for a custom entity type like this:
function mymodule_install() {
if (!field_info_field('mymodule_field')) {
$field = array( .... );
field_create_field($field);
}
if (!field_info_instance('mymodule_entity','mymodule_field', 'bundle1')) {
$instance = array( .... );
field_create_instance($instance);
}
}
function mymodule_uninstall() {
if ($instance = field_info_instance('mymodule_entity','mymodule_field', 'bundle1')) {
field_delete_instance($instance);
}
if (field_info_field('mymodule_field')) {
field_delete_field('mymodule_field');
}
field_purge_batch(100);
}
...and the field and instance gets created properly. However upon uninstalling the module, only the field tables are being deleted while the field instance is still there in the field_config_instance
table still having deleted = 0.
Debugging the uninstall process reveals that field_info_instance
(and field_read_instances
) is returning NULL...
Anyone knows what I'm doing wrong? I'm on a fresh Drupal 7.23 install...