? .cache
? .settings
Index: modules/field/field.info.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.info.inc,v
retrieving revision 1.28
diff -u -p -r1.28 field.info.inc
--- modules/field/field.info.inc	13 Nov 2009 11:59:14 -0000	1.28
+++ modules/field/field.info.inc	18 Nov 2009 21:43:18 -0000
@@ -452,50 +452,16 @@ function field_info_bundles($obj_type = 
 }
 
 /**
- * Return array of all field data, keyed by field name.
+ * Return all field efinitions.
  *
- * @param $bundle_type
- *   (optional) The bundle type on which to filter the list of fields. In the
- *   case of nodes, this is the node type.
- * @param $field
- *   (optional) A field array or name on which to filter the list.
- * @param $field_type
- *   (optional) A field type on which to filter the list.
  * @return
- *   An array of Field objects. Each Field object has an additional
- *   property, bundles, which is an array of all the bundles to which
- *   this field belongs.
+ *   An array of field definitions, keyd by field name. Each field has an
+ *   additional property, 'bundles', which is an array of all the bundles to
+ *   which this field belongs.
  */
-function field_info_fields($bundle_type = NULL, $field = NULL, $field_type = NULL) {
-  // Build the list of fields to be used for retrieval.
-  if (isset($field)) {
-    if (is_string($field)) {
-      $field = field_info_field($field);
-    }
-    $fields = array($field['field_name'] => $field);
-  }
-  elseif (isset($bundle_type)) {
-    $instances = field_info_instances($bundle_type);
-    $fields = array();
-    foreach ($instances as $field_name => $instance) {
-      $fields[$field_name] = field_info_field($field_name);
-    }
-  }
-  else {
-    $info = _field_info_collate_fields();
-    $fields = $info['fields'];
-  }
-
-  // If a field type was given, filter the list down to fields of that type.
-  if (isset($field_type)) {
-    foreach ($fields as $key => $field) {
-      if ($field['type'] != $field_type) {
-        unset($fields[$key]);
-      }
-    }
-  }
-
-  return $fields;
+function field_info_fields() {
+  $info = _field_info_collate_fields();
+  return $info['fields'];
 }
 
 /**
Index: modules/file/file.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/file/file.module,v
retrieving revision 1.11
diff -u -p -r1.11 file.module
--- modules/file/file.module	31 Oct 2009 16:06:36 -0000	1.11
+++ modules/file/file.module	18 Nov 2009 21:43:46 -0000
@@ -857,36 +857,49 @@ function file_icon_map($file) {
  *   An integer value.
  */
 function file_get_file_reference_count($file, $field = NULL, $field_type = 'file') {
-  $fields = field_info_fields(NULL, $field, $field_type);
+  // Determine the collection of fields to check.
+  if (isset($field)) {
+    // Support $field as 'field name'.
+    if (is_string($field)) {
+      $field = field_info_field($field);
+    }
+    $fields = array($field);
+  }
+  else {
+    $fields = field_info_fields();
+  }
+
   $types = entity_get_info();
   $reference_count = 0;
 
   foreach ($fields as $field) {
-    // TODO: Use a more efficient mechanism rather than actually retrieving
-    // all the references themselves, such as using a COUNT() query.
-    $references = file_get_file_references($file, $field, FIELD_LOAD_REVISION, $field_type);
-    foreach ($references as $obj_type => $type_references) {
-      $reference_count += count($type_references);
-    }
+    if (empty($field_type) || $field['type'] == $field_type) {
+      // TODO: Use a more efficient mechanism rather than actually retrieving
+      // all the references themselves, such as using a COUNT() query.
+      $references = file_get_file_references($file, $field, FIELD_LOAD_REVISION, $field_type);
+      foreach ($references as $obj_type => $type_references) {
+        $reference_count += count($type_references);
+      }
 
-    // If a field_name is present in the file object, the file is being deleted
-    // from this field.
-    if (isset($file->file_field_name) && $field['field_name'] == $file->file_field_name) {
-      // If deleting the entire piece of content, decrement references.
-      if (isset($file->file_field_type) && isset($file->file_field_id)) {
-        if ($file->file_field_type == $obj_type) {
-          $info = entity_get_info($obj_type);
-          $id = $types[$obj_type]['object keys']['id'];
-          foreach ($type_references as $reference) {
-            if ($file->file_field_id == $reference->$id) {
-              $reference_count--;
+      // If a field_name is present in the file object, the file is being deleted
+      // from this field.
+      if (isset($file->file_field_name) && $field['field_name'] == $file->file_field_name) {
+        // If deleting the entire piece of content, decrement references.
+        if (isset($file->file_field_type) && isset($file->file_field_id)) {
+          if ($file->file_field_type == $obj_type) {
+            $info = entity_get_info($obj_type);
+            $id = $types[$obj_type]['object keys']['id'];
+            foreach ($type_references as $reference) {
+              if ($file->file_field_id == $reference->$id) {
+                $reference_count--;
+              }
             }
           }
         }
-      }
-      // Otherwise we're just deleting a single reference in this field.
-      else {
-        $reference_count--;
+        // Otherwise we're just deleting a single reference in this field.
+        else {
+          $reference_count--;
+        }
       }
     }
   }
@@ -915,7 +928,7 @@ function file_get_file_reference_count($
  */
 function file_get_file_references($file, $field = NULL, $age = FIELD_LOAD_REVISION, $field_type = 'file') {
   $references = drupal_static(__FUNCTION__, array());
-  $fields = field_info_fields(NULL, $field, $field_type);
+  $fields = field_info_fields(NULL, NULL, $field, $field_type);
 
   foreach ($fields as $field_name => $file_field) {
     if (!isset($references[$field_name])) {
