field_info_instances() returns an empty set in hook_uninstall but not in module file Why would field_info_instances() return an empty set in hook_uninstall() when it returns the expected results in the main module file?

I've used the exact same code to delete the fields for a set of bundles in both the .install file and the main .module file:

  $bundles = array('property', 'open_house', 'agent', 'office');
  // Delete fields
  foreach ($bundles as $bundle) {
    $instances = field_info_instances('content', $bundle);
    if (!empty($instances)) {
      foreach ($instances as $instance) {
        dpm($instance);
        //field_delete_instance($instance);
      }
    }
  }


The following code (pulled from _field_info_collate_fields() in field.info.inc) outputs the fields in a list:

  $definitions = array(
    'field_ids' =&gt; field_read_fields(array(), array('include_deleted' =&gt; 1)), 
    'instances' =&gt; field_read_instances(),
  );


as shown here:


 ... (Array, 2 elements)

     field_ids (Array, 149 elements)
     instances (Array, 8 elements)


It was suggested that I need to use drupal_load() and/or drupal_load_include() to load the field module or field.info.inc to use the field_info_instances() function. I also tried using drupal_load() to load my module, but the following code also does not work:

  $bundles = array('property', 'open_house', 'agent', 'office');
  drupal_load('module', 'field');
  module_load_include('inc', 'field.module', 'field.info');

  // Delete fields
  foreach ($bundles as $bundle) {
    $instances = field_info_instances('content', $bundle);
    dpm($instances);
    if (!empty($instances)) {
      foreach ($instances as $instance) {
        field_delete_instance($instance);
      }
    }
  }


Does anyone know why field_info_instances() would be unable to read the information about the field instances?

UPDATE:

When I run the following code: dpm(field_read_instances(null, array('include_inactive' =&gt; TRUE))); my fields are displayed.  Why are they inactive, is it because the module is being uninstalled and is disabled?  What should I do to work around this?
I found out that this has been fixed in 7.8. #943772 by jpsoto, yched, catch, bojanz, pillarsdotnet, steinmb: Fixed field_delete_field() and others fail for inactive fields.