? MISC-FIELD-CHANGES-REAPPLY.patch
? Makefile
? d6-50-nodes.sql.gz
? d7-50-nodes-new.sql.gz
? d7-50-nodes.sql.gz
? head.kpf
? patches
? modules/field/modules/options/options.test
? scripts/OLD-generate-autoload.pl
? scripts/generate-autoload.pl
? sites/all/cck
? sites/all/modules/color
? sites/all/modules/combofield
? sites/all/modules/devel
? sites/all/modules/pbs
? sites/all/modules/taint
? sites/default/files
? sites/default/private
? sites/default/settings.php
Index: modules/comment/comment.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.install,v
retrieving revision 1.47
diff -u -F^[fc] -r1.47 comment.install
--- modules/comment/comment.install	29 Sep 2009 15:13:55 -0000	1.47
+++ modules/comment/comment.install	10 Oct 2009 12:42:01 -0000
@@ -117,7 +117,7 @@ function comment_update_7004() {
  */
 function comment_update_7005() {
   foreach (node_type_get_types() as $info) {
-    field_attach_create_bundle('comment_node_' . $info->type);
+    field_attach_create_bundle('comment', 'comment_node_' . $info->type);
   }
 }
 
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.780
diff -u -F^[fc] -r1.780 comment.module
--- modules/comment/comment.module	9 Oct 2009 17:05:52 -0000	1.780
+++ modules/comment/comment.module	10 Oct 2009 12:42:01 -0000
@@ -233,7 +233,7 @@ function comment_count_unpublished() {
  * Implement hook_node_type_insert().
  */
 function comment_node_type_insert($info) {
-  field_attach_create_bundle('comment_node_' . $info->type);
+  field_attach_create_bundle('comment', 'comment_node_' . $info->type);
 }
 
 /**
@@ -241,7 +241,7 @@ function comment_node_type_insert($info)
  */
 function comment_node_type_update($info) {
   if (!empty($info->old_type) && $info->type != $info->old_type) {
-    field_attach_rename_bundle('comment_node_' . $info->old_type, 'comment_node_' . $info->type);
+    field_attach_rename_bundle('comment', 'comment_node_' . $info->old_type, 'comment_node_' . $info->type);
   }
 }
 
@@ -249,7 +249,7 @@ function comment_node_type_update($info)
  * Implement hook_node_type_delete().
  */
 function comment_node_type_delete($info) {
-  field_attach_delete_bundle('comment_node_' . $info->type);
+  field_attach_delete_bundle('comment', 'comment_node_' . $info->type);
   $settings = array(
     'comment',
     'comment_default_mode',
Index: modules/field/field.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.api.php,v
retrieving revision 1.39
diff -u -F^[fc] -r1.39 field.api.php
--- modules/field/field.api.php	9 Oct 2009 19:22:55 -0000	1.39
+++ modules/field/field.api.php	10 Oct 2009 12:42:01 -0000
@@ -1063,7 +1063,7 @@ function hook_field_attach_view_alter($o
  *
  * See field_attach_create_bundle() for details and arguments.
  */
-function hook_field_attach_create_bundle($bundle) {
+function hook_field_attach_create_bundle($obj_type, $bundle) {
 }
 
 /**
@@ -1073,7 +1073,7 @@ function hook_field_attach_create_bundle
  *
  * See field_attach_rename_bundle() for details and arguments.
  */
-function hook_field_attach_rename_bundle($bundle_old, $bundle_new) {
+function hook_field_attach_rename_bundle($obj_type, $bundle_old, $bundle_new) {
 }
 
 /**
@@ -1081,13 +1081,15 @@ function hook_field_attach_rename_bundle
  *
  * This hook is invoked after the field module has performed the operation.
  *
+ * @param $obj_type
+ *   The type of object; e.g. 'node' or 'user'.
  * @param $bundle
  *   The bundle that was just deleted.
  * @param $instances
- *   An array of all instances that existed for $bundle before it was
+ *   An array of all instances that existed for the bundle before it was
  *   deleted.
  */
-function hook_field_attach_delete_bundle($bundle, $instances) {
+function hook_field_attach_delete_bundle($obj_type, $bundle, $instances) {
 }
 
 /**
Index: modules/field/field.attach.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.attach.inc,v
retrieving revision 1.51
diff -u -F^[fc] -r1.51 field.attach.inc
--- modules/field/field.attach.inc	2 Oct 2009 14:39:43 -0000	1.51
+++ modules/field/field.attach.inc	10 Oct 2009 12:42:01 -0000
@@ -184,10 +184,10 @@ function _field_invoke($op, $obj_type, $
   list(, , $bundle) = field_extract_ids($obj_type, $object);
 
   if ($options['deleted']) {
-    $instances = field_read_instances(array('bundle' => $bundle), array('include_deleted' => $options['deleted']));
+    $instances = field_read_instances(array('object_type' => $obj_type, 'bundle' => $bundle), array('include_deleted' => $options['deleted']));
   }
   else {
-    $instances = field_info_instances($bundle);
+    $instances = field_info_instances($obj_type, $bundle);
   }
 
   foreach ($instances as $instance) {
@@ -304,7 +304,7 @@ function _field_invoke_multiple($op, $ob
       $instances = field_read_field(array('bundle' => $bundle, array('include_deleted' => $options['deleted'])));
     }
     else {
-      $instances = field_info_instances($bundle);
+      $instances = field_info_instances($obj_type, $bundle);
     }
 
     foreach ($instances as $instance) {
@@ -593,10 +593,10 @@ function field_attach_load($obj_type, $o
     foreach ($queried_objects as $obj) {
       list($id, $vid, $bundle) = field_extract_ids($obj_type, $obj);
       if ($options['deleted']) {
-        $instances = field_read_instances(array('bundle' => $bundle), array('include_deleted' => $options['deleted']));
+        $instances = field_read_instances(array('object_type' => $obj_type, 'bundle' => $bundle), array('include_deleted' => $options['deleted']));
       }
       else {
-        $instances = field_info_instances($bundle);
+        $instances = field_info_instances($obj_type, $bundle);
       }
 
       foreach ($instances as $instance) {
@@ -637,7 +637,7 @@ function field_attach_load($obj_type, $o
       foreach ($queried_objects as $id => $object) {
         $data = array();
         list($id, $vid, $bundle) = field_extract_ids($obj_type, $object);
-        $instances = field_info_instances($bundle);
+        $instances = field_info_instances($obj_type, $bundle);
         foreach ($instances as $instance) {
           $data[$instance['field_name']] = $queried_objects[$id]->{$instance['field_name']};
         }
@@ -831,7 +831,7 @@ function field_attach_insert($obj_type, 
 
   // Collect the storage backends used by the remaining fields in the objects.
   $storages = array();
-  foreach (field_info_instances($bundle) as $instance) {
+  foreach (field_info_instances($obj_type, $bundle) as $instance) {
     $field = field_info_field_by_id($instance['field_id']);
     $field_id = $field['id'];
     $field_name = $field['field_name'];
@@ -877,7 +877,7 @@ function field_attach_update($obj_type, 
 
   // Collect the storage backends used by the remaining fields in the objects.
   $storages = array();
-  foreach (field_info_instances($bundle) as $instance) {
+  foreach (field_info_instances($obj_type, $bundle) as $instance) {
     $field = field_info_field_by_id($instance['field_id']);
     $field_id = $field['id'];
     $field_name = $field['field_name'];
@@ -920,7 +920,7 @@ function field_attach_delete($obj_type, 
 
   // Collect the storage backends used by the fields in the objects.
   $storages = array();
-  foreach (field_info_instances($bundle) as $instance) {
+  foreach (field_info_instances($obj_type, $bundle) as $instance) {
     $field = field_info_field_by_id($instance['field_id']);
     $field_id = $field['id'];
     $storages[$field['storage']['type']][$field_id] = $field_id;
@@ -959,7 +959,7 @@ function field_attach_delete_revision($o
 
   // Collect the storage backends used by the fields in the objects.
   $storages = array();
-  foreach (field_info_instances($bundle) as $instance) {
+  foreach (field_info_instances($obj_type, $bundle) as $instance) {
     $field = field_info_field_by_id($instance['field_id']);
     $field_id = $field['id'];
     $storages[$field['storage']['type']][$field_id] = $field_id;
@@ -1219,7 +1219,7 @@ function field_attach_view($obj_type, $o
 function field_attach_preprocess($obj_type, $object, $element, &$variables) {
   list(, , $bundle) = field_extract_ids($obj_type, $object);
 
-  foreach (field_info_instances($bundle) as $instance) {
+  foreach (field_info_instances($obj_type, $bundle) as $instance) {
     $field_name = $instance['field_name'];
     if (isset($element[$field_name]['#language'])) {
       $langcode = $element[$field_name]['#language'];
@@ -1275,30 +1275,33 @@ function field_attach_prepare_translatio
  * The default SQL-based storage doesn't need to do anytrhing about it, but
  * others might.
  *
+ * TODO THIS PATCH
  * @param $bundle
  *   The name of the newly created bundle.
  */
-function field_attach_create_bundle($bundle) {
+function field_attach_create_bundle($obj_type, $bundle) {
   // Clear the cache.
   field_cache_clear();
 
   foreach (module_implements('field_attach_create_bundle') as $module) {
     $function = $module . '_field_attach_create_bundle';
-    $function($bundle);
+    $function($obj_type, $bundle);
   }
 }
 
 /**
  * Notify field.module that a bundle was renamed.
  *
+ * TODO THIS PATCH
  * @param $bundle_old
  *   The previous name of the bundle.
  * @param $bundle_new
  *   The new name of the bundle.
  */
-function field_attach_rename_bundle($bundle_old, $bundle_new) {
+function field_attach_rename_bundle($obj_type, $bundle_old, $bundle_new) {
   db_update('field_config_instance')
     ->fields(array('bundle' => $bundle_new))
+    ->condition('object_type', $obj_type)
     ->condition('bundle', $bundle_old)
     ->execute();
 
@@ -1307,7 +1310,7 @@ function field_attach_rename_bundle($bun
 
   foreach (module_implements('field_attach_rename_bundle') as $module) {
     $function = $module . '_field_attach_rename_bundle';
-    $function($bundle_old, $bundle_new);
+    $function($obj_type, $bundle_old, $bundle_new);
   }
 }
 
@@ -1321,12 +1324,13 @@ function field_attach_rename_bundle($bun
  * (particularly since for some field types, the deletion is more than just a
  * simple DELETE query).
  *
+ * TODO THIS PATCH
  * @param $bundle
  *   The bundle to delete.
  */
-function field_attach_delete_bundle($bundle) {
+function field_attach_delete_bundle($obj_type, $bundle) {
   // First, delete the instances themseves.
-  $instances = field_info_instances($bundle);
+  $instances = field_info_instances($obj_type, $bundle);
   foreach ($instances as $instance) {
     field_delete_instance($instance);
   }
@@ -1337,7 +1341,7 @@ function field_attach_delete_bundle($bun
   // Let other modules act on deleting the bundle.
   foreach (module_implements('field_attach_delete_bundle') as $module) {
     $function = $module . '_field_attach_delete_bundle';
-    $function($bundle, $instances);
+    $function($obj_type, $bundle, $instances);
   }
 }
 
Index: modules/field/field.crud.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.crud.inc,v
retrieving revision 1.38
diff -u -F^[fc] -r1.38 field.crud.inc
--- modules/field/field.crud.inc	2 Oct 2009 14:39:43 -0000	1.38
+++ modules/field/field.crud.inc	10 Oct 2009 12:42:01 -0000
@@ -16,6 +16,7 @@
  * particular type of data that can be attached to objects. A Field
  * Instance is a Field attached to a single Bundle. A Bundle is a set
  * of fields that are treated as a group by the Field Attach API.
+ * TODO...
  *
  * For example, suppose a site administrator wants Article nodes to
  * have a subtitle and photo. Using the Field API or some UI module,
@@ -103,6 +104,8 @@
  *     It is populated automatically by field_create_instance().
  * - field_name (string)
  *     The name of the field attached to the bundle by this instance.
+ * - object_type (string)
+ *     The name of the object type the instance is attached to.
  * - bundle (string)
  *     The name of the bundle that the field is attached to.
  * - label (string)
@@ -540,9 +543,11 @@ function field_delete_field($field_name)
   // Delete all non-deleted instances.
   $field = field_info_field($field_name);
   if (isset($field['bundles'])) {
-    foreach ($field['bundles'] as $bundle) {
-      $instance = field_info_instance($field_name, $bundle);
-      field_delete_instance($instance);
+    foreach ($field['bundles'] as $obj_type => $bundles) {
+      foreach ($bundles as $bundle) {
+        $instance = field_info_instance($obj_type, $field_name, $bundle);
+        field_delete_instance($instance);
+      }
     }
   }
 
@@ -565,9 +570,9 @@ function field_delete_field($field_name)
  * Creates an instance of a field, binding it to a bundle.
  *
  * @param $instance
- *   A field instance structure. The field_name and bundle properties are
- *   required.
- *   Other properties, if omitted, will be given the following default values:
+ *   A field instance structure. The field_name, object_type and
+ *   bundle properties are required. Other properties, if omitted,
+ *   will be given the following default values:
  *   - label: the field name
  *   - description: empty string
  *   - weight: 0
@@ -592,11 +597,17 @@ function field_delete_field($field_name)
  *   FieldException
  */
 function field_create_instance($instance) {
-  // Check that the specified field exists.
   $field = field_read_field($instance['field_name']);
   if (empty($field)) {
     throw new FieldException("Attempt to create an instance of a field that doesn't exist or is currently inactive.");
   }
+  // Check that the required properties exists.
+  if (empty($instance['object_type'])) {
+    throw new FieldException(t('Attempt to create an instance of field @field_name without an object type.', array('@field_name' => $instance['field_name'])));
+  }
+  if (empty($instance['bundle'])) {
+    throw new FieldException(t('Attempt to create an instance of field @field_name without a bundle.', array('@field_name' => $instance['field_name'])));
+  }
 
   // Set the field id.
   $instance['field_id'] = $field['id'];
@@ -614,7 +625,7 @@ function field_create_instance($instance
   // Ensure the field instance is unique within the bundle.
   // We only check for instances of active fields, since adding an instance of
   // a disabled field is not supported.
-  $prior_instance = field_read_instance($instance['field_name'], $instance['bundle']);
+  $prior_instance = field_read_instance($instance['object_type'], $instance['field_name'], $instance['bundle']);
   if (!empty($prior_instance)) {
     $message = t('Attempt to create a field instance that already exists.');
     throw new FieldException($message);
@@ -655,7 +666,7 @@ function field_update_instance($instance
 
   // Check that the field instance exists (even if it is inactive, since we
   // want to be able to replace inactive widgets with new ones).
-  $prior_instance = field_read_instance($instance['field_name'], $instance['bundle'], array('include_inactive' => TRUE));
+  $prior_instance = field_read_instance($instance['object_type'], $instance['field_name'], $instance['bundle'], array('include_inactive' => TRUE));
   if (empty($prior_instance)) {
     throw new FieldException("Attempt to update a field instance that doesn't exist.");
   }
@@ -736,6 +747,7 @@ function _field_write_instance($instance
   $record = array(
     'field_id' => $instance['field_id'],
     'field_name' => $instance['field_name'],
+    'object_type' => $instance['object_type'],
     'bundle' => $instance['bundle'],
     'data' => $data,
     'deleted' => $instance['deleted'],
@@ -759,6 +771,8 @@ function _field_write_instance($instance
  * This function will not return deleted instances. Use
  * field_read_instances() instead for this purpose.
  *
+ * @param $obj_type
+ *   The type of object to which the field is bound.
  * @param $field_name
  *   The field name to read.
  * @param $bundle
@@ -772,8 +786,8 @@ function _field_write_instance($instance
  * @return
  *   An instance structure, or FALSE.
  */
-function field_read_instance($field_name, $bundle, $include_additional = array()) {
-  $instances = field_read_instances(array('field_name' => $field_name, 'bundle' => $bundle), $include_additional);
+function field_read_instance($obj_type, $field_name, $bundle, $include_additional = array()) {
+  $instances = field_read_instances(array('object_type' => $obj_type, 'field_name' => $field_name, 'bundle' => $bundle), $include_additional);
   return $instances ? current($instances) : FALSE;
 }
 
@@ -820,6 +834,7 @@ function field_read_instances($params = 
     $instance['id'] = $record['id'];
     $instance['field_id'] = $record['field_id'];
     $instance['field_name'] = $record['field_name'];
+    $instance['object_type'] = $record['object_type'];
     $instance['bundle'] = $record['bundle'];
     $instance['deleted'] = $record['deleted'];
 
@@ -841,6 +856,7 @@ function field_delete_instance($instance
   db_update('field_config_instance')
     ->fields(array('deleted' => 1))
     ->condition('field_name', $instance['field_name'])
+    ->condition('object_type', $instance['object_type'])
     ->condition('bundle', $instance['bundle'])
     ->execute();
 
Index: modules/field/field.default.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.default.inc,v
retrieving revision 1.19
diff -u -F^[fc] -r1.19 field.default.inc
--- modules/field/field.default.inc	9 Oct 2009 19:22:55 -0000	1.19
+++ modules/field/field.default.inc	10 Oct 2009 12:42:01 -0000
@@ -75,9 +75,9 @@ function field_default_view($obj_type, $
 
     $info = array(
       '#field_name' => $field['field_name'],
+      '#object_type' => $obj_type,
       '#bundle' => $bundle,
       '#object' => $object,
-      '#object_type' => $obj_type,
     );
 
     $element = $info + array(
Index: modules/field/field.form.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.form.inc,v
retrieving revision 1.28
diff -u -F^[fc] -r1.28 field.form.inc
--- modules/field/field.form.inc	9 Oct 2009 19:22:56 -0000	1.28
+++ modules/field/field.form.inc	10 Oct 2009 12:42:01 -0000
@@ -66,6 +66,7 @@ function field_default_form($obj_type, $
           '#delta' => $delta,
           '#field_name' => $field['field_name'],
           '#bundle' => $instance['bundle'],
+          '#object_type' => $instance['object_type'],
         );
         $element = array_merge($element, $defaults);
         // If we're processing a specific delta value for a field where the
@@ -168,6 +169,7 @@ function field_multiple_value_form($fiel
           '#delta' => $delta,
           '#columns' => array_keys($field['columns']),
           '#field_name' => $field_name,
+          '#object_type' => $instance['object_type'],
           '#bundle' => $instance['bundle'],
         );
 
Index: modules/field/field.info.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.info.inc,v
retrieving revision 1.19
diff -u -F^[fc] -r1.19 field.info.inc
--- modules/field/field.info.inc	27 Sep 2009 12:52:55 -0000	1.19
+++ modules/field/field.info.inc	10 Oct 2009 12:42:01 -0000
@@ -190,8 +190,8 @@ function _field_info_collate_types($rese
  *   - fields_id: Array of existing fields, keyed by field id. This entry lists
  *     both deleted and non-deleted fields. The bundles element is the same as
  *     for 'fields'.
- *   - instances: Array of existing instances, keyed by bundle name and field
- *     name. This entry only lists non-deleted instances.
+ *   - instances: Array of existing instances, keyed by object type, bundle
+ *     name and field name. This entry only lists non-deleted instances. 
  */
 function _field_info_collate_fields($reset = FALSE) {
   static $info;
@@ -236,13 +236,13 @@ function _field_info_collate_fields($res
     foreach ($definitions['instances'] as $instance) {
       $field = $info['fields'][$instance['field_name']];
       $instance = _field_info_prepare_instance($instance, $field);
-      $info['instances'][$instance['bundle']][$instance['field_name']] = $instance;
+      $info['instances'][$instance['object_type']][$instance['bundle']][$instance['field_name']] = $instance;
       // Enrich field definitions with the list of bundles where they have
       // instances. NOTE: Deleted fields in $info['field_ids'] are not
       // enriched because all of their instances are deleted, too, and
       // are thus not in $definitions['instances'].
-      $info['fields'][$instance['field_name']]['bundles'][] = $instance['bundle'];
-      $info['field_ids'][$instance['field_id']]['bundles'][] = $instance['bundle'];
+      $info['fields'][$instance['field_name']]['bundles'][$instance['object_type']][] = $instance['bundle'];
+      $info['field_ids'][$instance['field_id']]['bundles'][$instance['object_type']][] = $instance['bundle'];
     }
   }
 
@@ -308,8 +308,7 @@ function _field_info_prepare_instance($i
   }
 
   // Fallback to 'full' display settings for unspecified build modes.
-  $obj_type = field_info_bundle_entity($instance['bundle']);
-  foreach (field_build_modes($obj_type) as $build_mode => $label) {
+  foreach (field_build_modes($instance['object_type']) as $build_mode => $label) {
     if (!isset($instance['display'][$build_mode])) {
       $instance['display'][$build_mode] = $instance['display']['full'];
     }
@@ -475,16 +474,26 @@ function field_info_fieldable_types($obj
 }
 
 /**
- * Return an array of fieldable bundle names and labels, for an individual
- * object type or for all object types.
+ * Return information about existing bundles.
+ *
+ * @param $obj_type
+ *   The type of object; e.g. 'node' or 'user'.
+ *
+ * @return
+ *   An array of bundles for the $obj_type keyed by bundle name,
+ *   or, if no $obj_type was provided, the array of all existing bundles,
+ *   keyed by object type.
  */
 function field_info_bundles($obj_type = NULL) {
   $info = _field_info_collate_types();
+
+  if ($obj_type) {
+    return isset($info['fieldable types'][$obj_type]['bundles']) ? $info['fieldable types'][$obj_type]['bundles'] : array();
+  }
+
   $bundles = array();
   foreach ($info['fieldable types'] as $type => $fieldable_info) {
-    if (empty($obj_type) || $obj_type == $type) {
-      $bundles += $fieldable_info['bundles'];
-    }
+    $bundles[$type] = $fieldable_info['bundles'];
   }
   return $bundles;
 }
@@ -556,28 +565,29 @@ function field_info_field_by_id($field_i
 /**
  * Return an array of instance data for a given bundle,
  * or for all known bundles, keyed by bundle name and field name.
- *
+ * TODO
  * @param $bundle_name
  *   If set, return information on just this bundle.
  */
-function field_info_instances($bundle_name = NULL) {
+function field_info_instances($obj_type, $bundle_name = NULL) {
   $info = _field_info_collate_fields();
   if (!isset($bundle_name)) {
-    return $info['instances'];
+    return $info['instances'][$obj_type];
   }
-  if (isset($info['instances'][$bundle_name])) {
-    return $info['instances'][$bundle_name];
+  if (isset($info['instances'][$obj_type][$bundle_name])) {
+    return $info['instances'][$obj_type][$bundle_name];
   }
   return array();
 }
 
 /**
  * Return an array of instance data for a specific field and bundle.
+ * TODO
  */
-function field_info_instance($field_name, $bundle_name) {
+function field_info_instance($obj_type, $field_name, $bundle_name) {
   $info = _field_info_collate_fields();
-  if (isset($info['instances'][$bundle_name][$field_name])) {
-    return $info['instances'][$bundle_name][$field_name];
+  if (isset($info['instances'][$obj_type][$bundle_name][$field_name])) {
+    return $info['instances'][$obj_type][$bundle_name][$field_name];
   }
 }
 
Index: modules/field/field.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.install,v
retrieving revision 1.15
diff -u -F^[fc] -r1.15 field.install
--- modules/field/field.install	1 Oct 2009 19:16:57 -0000	1.15
+++ modules/field/field.install	10 Oct 2009 12:42:01 -0000
@@ -130,6 +130,12 @@ function field_schema() {
         'not null' => TRUE,
         'default' => ''
       ),
+      'object_type'       => array(
+        'type' => 'varchar',
+        'length' => 32,
+        'not null' => TRUE,
+        'default' => ''
+      ),
       'bundle' => array(
         'type' => 'varchar',
         'length' => 128,
@@ -152,7 +158,7 @@ function field_schema() {
     'primary key' => array('id'),
     'indexes' => array(
       // Used by field_delete_instance().
-      'field_name_bundle' => array('field_name', 'bundle'),
+      'field_name_bundle' => array('field_name', 'object_type', 'bundle'),
       // Used by field_read_instances().
       'deleted' => array('deleted'),
     ),
Index: modules/field/field.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.module,v
retrieving revision 1.39
diff -u -F^[fc] -r1.39 field.module
--- modules/field/field.module	9 Oct 2009 19:22:56 -0000	1.39
+++ modules/field/field.module	10 Oct 2009 12:42:01 -0000
@@ -504,7 +504,7 @@ function field_format($obj_type, $object
 
     // We need $field, $instance, $obj_type, $object to be able to display a value...
     list(, , $bundle) = field_extract_ids($obj_type, $object);
-    $instance = field_info_instance($field['field_name'], $bundle);
+    $instance = field_info_instance($obj_type, $field['field_name'], $bundle);
 
     $display = array(
       'type' => $formatter_type ? $formatter_type : $field_type['default_formatter'],
@@ -518,6 +518,7 @@ function field_format($obj_type, $object
       $element = array(
         '#theme' => $theme,
         '#field_name' => $field['field_name'],
+        '#object_type' => $obj_type,
         '#bundle' => $bundle,
         '#formatter' => $display['type'],
         '#settings' => $display['settings'],
@@ -738,7 +739,7 @@ function field_create_stub_entity($obj_t
 function template_preprocess_field(&$variables) {
   $element = $variables['element'];
   list(, , $bundle) = field_extract_ids($element['#object_type'], $element['#object']);
-  $instance = field_info_instance($element['#field_name'], $bundle);
+  $instance = field_info_instance($element['#object_type'], $element['#field_name'], $bundle);
   $field = field_info_field($element['#field_name']);
 
   $field_type_css = strtr($field['type'], '_', '-');
Index: modules/field/field.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.test,v
retrieving revision 1.58
diff -u -F^[fc] -r1.58 field.test
--- modules/field/field.test	2 Oct 2009 14:39:43 -0000	1.58
+++ modules/field/field.test	10 Oct 2009 12:42:01 -0000
@@ -51,6 +51,7 @@ class FieldAttachTestCase extends FieldT
     $this->field_id = $this->field['id'];
     $this->instance = array(
       'field_name' => $this->field_name,
+      'object_type' => 'test_entity',
       'bundle' => 'test_bundle',
       'label' => $this->randomName() . '_label',
       'description' => $this->randomName() . '_description',
@@ -179,6 +180,7 @@ class FieldAttachStorageTestCase extends
       foreach ($field_bundles_map[$i] as $bundle) {
         $instance = array(
           'field_name' => $field_names[$i],
+          'object_type' => 'test_entity',
           'bundle' => $bundles[$bundle],
           'settings' => array(
             // Configure the instance so that we test hook_field_load()
@@ -194,7 +196,7 @@ class FieldAttachStorageTestCase extends
     foreach ($bundles as $index => $bundle) {
       $entities[$index] = field_test_create_stub_entity($index, $index, $bundle);
       $entity = clone($entities[$index]);
-      $instances = field_info_instances($bundle);
+      $instances = field_info_instances('test_entity', $bundle);
       foreach ($instances as $field_name => $instance) {
         $values[$index][$field_name] = mt_rand(1, 127);
         $entity->$field_name = array($langcode => array(array('value' => $values[$index][$field_name])));
@@ -205,7 +207,7 @@ class FieldAttachStorageTestCase extends
     // Check that a single load correctly loads field values for both entities.
     field_attach_load($entity_type, $entities);
     foreach ($entities as $index => $entity) {
-      $instances = field_info_instances($bundles[$index]);
+      $instances = field_info_instances($entity_type, $bundles[$index]);
       foreach ($instances as $field_name => $instance) {
         // The field value loaded matches the one inserted.
         $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], $values[$index][$field_name], t('Entity %index: expected value was found.', array('%index' => $index)));
@@ -249,6 +251,7 @@ class FieldAttachStorageTestCase extends
       field_create_field($field);
       $instance = array(
         'field_name' => $field['field_name'],
+        'object_type' => 'test_entity',
         'bundle' => 'test_bundle',
       );
       field_create_instance($instance);
@@ -470,7 +473,7 @@ class FieldAttachStorageTestCase extends
     field_test_rename_bundle($this->instance['bundle'], $new_bundle);
 
     // Check that the instance definition has been updated.
-    $this->instance = field_info_instance($this->field_name, $new_bundle);
+    $this->instance = field_info_instance($entity_type, $this->field_name, $new_bundle);
     $this->assertIdentical($this->instance['bundle'], $new_bundle, "Bundle name has been updated in the instance.");
 
     // Verify the field data is present on load.
@@ -498,6 +501,7 @@ class FieldAttachStorageTestCase extends
     field_create_field($field);
     $instance = array(
       'field_name' => $field_name,
+      'object_type' => 'test_entity',
       'bundle' => $this->instance['bundle'],
       'label' => $this->randomName() . '_label',
       'description' => $this->randomName() . '_description',
@@ -515,12 +519,11 @@ class FieldAttachStorageTestCase extends
     $values = $this->_generateTestFieldValues($this->field['cardinality']);
     $entity->{$this->field_name}[$langcode] = $values;
     $entity->{$field_name}[$langcode] = $this->_generateTestFieldValues(1);
-    $entity_type = 'test_entity';
-    field_attach_insert($entity_type, $entity);
+    field_attach_insert('test_entity', $entity);
 
     // Verify the fields are present on load
     $entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']);
-    field_attach_load($entity_type, array(0 => $entity));
+    field_attach_load('test_entity', array(0 => $entity));
     $this->assertEqual(count($entity->{$this->field_name}[$langcode]), 4, 'First field got loaded');
     $this->assertEqual(count($entity->{$field_name}[$langcode]), 1, 'Second field got loaded');
 
@@ -530,13 +533,13 @@ class FieldAttachStorageTestCase extends
 
     // Verify no data gets loaded
     $entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']);
-    field_attach_load($entity_type, array(0 => $entity));
+    field_attach_load('test_entity', array(0 => $entity));
     $this->assertFalse(isset($entity->{$this->field_name}[$langcode]), 'No data for first field');
     $this->assertFalse(isset($entity->{$field_name}[$langcode]), 'No data for second field');
 
     // Verify that the instances are gone
-    $this->assertFalse(field_read_instance($this->field_name, $this->instance['bundle']), "First field is deleted");
-    $this->assertFalse(field_read_instance($field_name, $instance['bundle']), "Second field is deleted");
+    $this->assertFalse(field_read_instance('test_entity', $this->field_name, $this->instance['bundle']), "First field is deleted");
+    $this->assertFalse(field_read_instance('test_entity', $field_name, $instance['bundle']), "Second field is deleted");
   }
 
   /**
@@ -552,6 +555,14 @@ class FieldAttachStorageTestCase extends
     $this->instance2['bundle'] = 'test_bundle_1';
     field_create_instance($this->instance2);
 
+    // Create instances of both fields on the second entity type.
+    $instance = $this->instance;
+    $instance['object_type'] = 'test_cacheable_entity';
+    field_create_instance($instance);
+    $instance2 = $this->instance2;
+    $instance2['object_type'] = 'test_cacheable_entity';
+    field_create_instance($instance2);
+
     // Create two test objects, using two different types and bundles.
     $entity_types = array(1 => 'test_entity', 2 => 'test_cacheable_entity');
     $entities = array(1 => field_test_create_stub_entity(1, 1, 'test_bundle'), 2 => field_test_create_stub_entity(2, 2, 'test_bundle_1'));
@@ -835,12 +846,9 @@ class FieldAttachOtherTestCase extends F
     $langcode = FIELD_LANGUAGE_NONE;
     $values = $this->_generateTestFieldValues($this->field['cardinality']);
 
-    $noncached_type = 'test_entity';
-    $cached_type = 'test_cacheable_entity';
-
-
     // Non-cacheable entity type.
-    $cid = "field:$noncached_type:{$entity_init->ftid}";
+    $entity_type = 'test_entity';
+    $cid = "field:$entity_type:{$entity_init->ftid}";
 
     // Check that no initial cache entry is present.
     $this->assertFalse(cache_get($cid, 'cache_field'), t('Non-cached: no initial cache entry'));
@@ -848,17 +856,21 @@ class FieldAttachOtherTestCase extends F
     // Save, and check that no cache entry is present.
     $entity = clone($entity_init);
     $entity->{$this->field_name}[$langcode] = $values;
-    field_attach_insert($noncached_type, $entity);
+    field_attach_insert($entity_type, $entity);
     $this->assertFalse(cache_get($cid, 'cache_field'), t('Non-cached: no cache entry on insert'));
 
     // Load, and check that no cache entry is present.
     $entity = clone($entity_init);
-    field_attach_load($noncached_type, array($entity->ftid => $entity));
+    field_attach_load($entity_type, array($entity->ftid => $entity));
     $this->assertFalse(cache_get($cid, 'cache_field'), t('Non-cached: no cache entry on load'));
 
 
     // Cacheable entity type.
-    $cid = "field:$cached_type:{$entity_init->ftid}";
+    $entity_type = 'test_cacheable_entity';
+    $cid = "field:$entity_type:{$entity_init->ftid}";
+    $instance = $this->instance;
+    $instance['object_type'] = $entity_type;
+    field_create_instance($instance);
 
     // Check that no initial cache entry is present.
     $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no initial cache entry'));
@@ -866,18 +878,18 @@ class FieldAttachOtherTestCase extends F
     // Save, and check that no cache entry is present.
     $entity = clone($entity_init);
     $entity->{$this->field_name}[$langcode] = $values;
-    field_attach_insert($cached_type, $entity);
+    field_attach_insert($entity_type, $entity);
     $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry on insert'));
 
     // Load a single field, and check that no cache entry is present.
     $entity = clone($entity_init);
-    field_attach_load($cached_type, array($entity->ftid => $entity), FIELD_LOAD_CURRENT, array('field_id' => $this->field_id));
+    field_attach_load($entity_type, array($entity->ftid => $entity), FIELD_LOAD_CURRENT, array('field_id' => $this->field_id));
     $cache = cache_get($cid, 'cache_field');
     $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry on loading a single field'));
 
     // Load, and check that a cache entry is present with the expected values.
     $entity = clone($entity_init);
-    field_attach_load($cached_type, array($entity->ftid => $entity));
+    field_attach_load($entity_type, array($entity->ftid => $entity));
     $cache = cache_get($cid, 'cache_field');
     $this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load'));
 
@@ -885,12 +897,12 @@ class FieldAttachOtherTestCase extends F
     $values = $this->_generateTestFieldValues($this->field['cardinality']);
     $entity = clone($entity_init);
     $entity->{$this->field_name}[$langcode] = $values;
-    field_attach_update($cached_type, $entity);
+    field_attach_update($entity_type, $entity);
     $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry on update'));
 
     // Load, and check that a cache entry is present with the expected values.
     $entity = clone($entity_init);
-    field_attach_load($cached_type, array($entity->ftid => $entity));
+    field_attach_load($entity_type, array($entity->ftid => $entity));
     $cache = cache_get($cid, 'cache_field');
     $this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load'));
 
@@ -899,18 +911,18 @@ class FieldAttachOtherTestCase extends F
     $values = $this->_generateTestFieldValues($this->field['cardinality']);
     $entity = clone($entity_init);
     $entity->{$this->field_name}[$langcode] = $values;
-    field_attach_update($cached_type, $entity);
+    field_attach_update($entity_type, $entity);
     $cache = cache_get($cid, 'cache_field');
     $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry on new revision creation'));
 
     // Load, and check that a cache entry is present with the expected values.
     $entity = clone($entity_init);
-    field_attach_load($cached_type, array($entity->ftid => $entity));
+    field_attach_load($entity_type, array($entity->ftid => $entity));
     $cache = cache_get($cid, 'cache_field');
     $this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load'));
 
     // Delete, and check that the cache entry is wiped.
-    field_attach_delete($cached_type, $entity);
+    field_attach_delete($entity_type, $entity);
     $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry after delete'));
   }
 
@@ -1075,7 +1087,7 @@ class FieldInfoTestCase extends FieldTes
 
     // Verify that no unexpected instances exist.
     $core_fields = field_info_fields();
-    $instances = field_info_instances(FIELD_TEST_BUNDLE);
+    $instances = field_info_instances('test_entity', FIELD_TEST_BUNDLE);
     $this->assertTrue(empty($instances), t('With no instances, info bundles is empty.'));
 
     // Create a field, verify it shows up.
@@ -1099,6 +1111,7 @@ class FieldInfoTestCase extends FieldTes
     // Create an instance, verify that it shows up
     $instance = array(
       'field_name' => $field['field_name'],
+      'object_type' => 'test_entity',
       'bundle' => FIELD_TEST_BUNDLE,
       'label' => $this->randomName(),
       'description' => $this->randomName(),
@@ -1110,7 +1123,7 @@ class FieldInfoTestCase extends FieldTes
           'test_setting' => 999)));
     field_create_instance($instance);
 
-    $instances = field_info_instances($instance['bundle']);
+    $instances = field_info_instances('test_entity', $instance['bundle']);
     $this->assertEqual(count($instances), 1, t('One instance shows up in info when attached to a bundle.'));
     $this->assertTrue($instance < $instances[$instance['field_name']], t('Instance appears in info correctly'));
   }
@@ -1157,6 +1170,7 @@ class FieldInfoTestCase extends FieldTes
     field_create_field($field_definition);
     $instance_definition = array(
       'field_name' => $field_definition['field_name'],
+      'object_type' => 'test_entity',
       'bundle' => FIELD_TEST_BUNDLE,
     );
     field_create_instance($instance_definition);
@@ -1180,7 +1194,7 @@ class FieldInfoTestCase extends FieldTes
     field_cache_clear();
 
     // Read the instance back.
-    $instance = field_info_instance($instance_definition['field_name'], $instance_definition['bundle']);
+    $instance = field_info_instance($instance_definition['object_type'], $instance_definition['field_name'], $instance_definition['bundle']);
 
     // Check that all expected instance settings are in place.
     $field_type = field_info_field_types($field_definition['type']);
@@ -1241,6 +1255,7 @@ class FieldFormTestCase extends FieldTes
     $this->field_unlimited = array('field_name' => drupal_strtolower($this->randomName()), 'type' => 'test_field', 'cardinality' => FIELD_CARDINALITY_UNLIMITED);
 
     $this->instance = array(
+      'object_type' => 'test_entity',
       'bundle' => 'test_bundle',
       'label' => $this->randomName() . '_label',
       'description' => $this->randomName() . '_description',
@@ -1754,6 +1769,7 @@ class FieldCrudTestCase extends FieldTes
     // Create instances for each.
     $this->instance_definition = array(
       'field_name' => $this->field['field_name'],
+      'object_type' => 'test_entity',
       'bundle' => FIELD_TEST_BUNDLE,
       'widget' => array(
         'type' => 'test_field_widget',
@@ -1776,7 +1792,7 @@ class FieldCrudTestCase extends FieldTes
 
     // Make sure that this field's instance is marked as deleted when it is
     // specifically loaded.
-    $instance = field_read_instance($this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE));
+    $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE));
     $this->assertTrue(!empty($instance['deleted']), t('An instance for a deleted field is marked for deletion.'));
 
     // Try to load the field normally and make sure it does not show up.
@@ -1784,13 +1800,13 @@ class FieldCrudTestCase extends FieldTes
     $this->assertTrue(empty($field), t('A deleted field is not loaded by default.'));
 
     // Try to load the instance normally and make sure it does not show up.
-    $instance = field_read_instance($this->instance_definition['field_name'], $this->instance_definition['bundle']);
+    $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
     $this->assertTrue(empty($instance), t('An instance for a deleted field is not loaded by default.'));
 
     // Make sure the other field (and its field instance) are not deleted.
     $another_field = field_read_field($this->another_field['field_name']);
     $this->assertTrue(!empty($another_field) && empty($another_field['deleted']), t('A non-deleted field is not marked for deletion.'));
-    $another_instance = field_read_instance($this->another_instance_definition['field_name'], $this->another_instance_definition['bundle']);
+    $another_instance = field_read_instance('test_entity', $this->another_instance_definition['field_name'], $this->another_instance_definition['bundle']);
     $this->assertTrue(!empty($another_instance) && empty($another_instance['deleted']), t('An instance of a non-deleted field is not marked for deletion.'));
 
     // Try to create a new field the same name as a deleted field and
@@ -1799,7 +1815,7 @@ class FieldCrudTestCase extends FieldTes
     field_create_instance($this->instance_definition);
     $field = field_read_field($this->field['field_name']);
     $this->assertTrue(!empty($field) && empty($field['deleted']), t('A new field with a previously used name is created.'));
-    $instance = field_read_instance($this->instance_definition['field_name'], $this->instance_definition['bundle']);
+    $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
     $this->assertTrue(!empty($instance) && empty($instance['deleted']), t('A new instance for a previously used field name is created.'));
 
     // Save an object with data for the field
@@ -1808,7 +1824,7 @@ class FieldCrudTestCase extends FieldTes
     $values[0]['value'] = mt_rand(1, 127);
     $entity->{$field['field_name']}[$langcode] = $values;
     $entity_type = 'test_entity';
-    field_attach_insert($entity_type, $entity);
+    field_attach_insert('test_entity', $entity);
 
     // Verify the field is present on load
     $entity = field_test_create_stub_entity(0, 0, $this->instance_definition['bundle']);
@@ -1851,7 +1867,7 @@ class FieldCrudTestCase extends FieldTes
     // Create a decimal 5.2 field.
     $field = array('field_name' => 'decimal53', 'type' => 'number_decimal', 'cardinality' => 3, 'settings' => array('precision' => 5, 'scale' => 2));
     $field = field_create_field($field);
-    $instance = array('field_name' => 'decimal53', 'bundle' => FIELD_TEST_BUNDLE);
+    $instance = array('field_name' => 'decimal53', 'object_type' => 'test_entity', 'bundle' => FIELD_TEST_BUNDLE);
     $instance = field_create_instance($instance);
 
     // Update it to a deciaml 5.3 field.
@@ -1982,6 +1998,8 @@ class FieldInstanceCrudTestCase extends 
     field_create_field($this->field);
     $this->instance_definition = array(
       'field_name' => $this->field['field_name'],
+      'object_type' => 'test_entity',
+      'object_type' => 'test_entity',
       'bundle' => FIELD_TEST_BUNDLE,
     );
   }
@@ -2003,7 +2021,6 @@ class FieldInstanceCrudTestCase extends 
     $record = $result->fetchAssoc();
     $record['data'] = unserialize($record['data']);
 
-    //$instance = field_read_instance($this->instance_definition['field_name'], $this->instance_definition['bundle']);
     $field_type = field_info_field_types($this->field['type']);
     $widget_type = field_info_widget_types($field_type['default_widget']);
     $formatter_type = field_info_formatter_types($field_type['default_formatter']);
@@ -2050,7 +2067,7 @@ class FieldInstanceCrudTestCase extends 
     field_create_instance($this->instance_definition);
 
     // Read the instance back.
-    $instance = field_read_instance($this->instance_definition['field_name'], $this->instance_definition['bundle']);
+    $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
     $this->assertTrue($this->instance_definition < $instance, t('The field was properly read.'));
   }
 
@@ -2062,7 +2079,7 @@ class FieldInstanceCrudTestCase extends 
     $field_type = field_info_field_types($this->field['type']);
 
     // Check that basic changes are saved.
-    $instance = field_read_instance($this->instance_definition['field_name'], $this->instance_definition['bundle']);
+    $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
     $instance['required'] = !$instance['required'];
     $instance['label'] = $this->randomName();
     $instance['description'] = $this->randomName();
@@ -2073,7 +2090,7 @@ class FieldInstanceCrudTestCase extends 
     $instance['display']['full']['weight']++;
     field_update_instance($instance);
 
-    $instance_new = field_read_instance($this->instance_definition['field_name'], $this->instance_definition['bundle']);
+    $instance_new = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
     $this->assertEqual($instance['required'], $instance_new['required'], t('"required" change is saved'));
     $this->assertEqual($instance['label'], $instance_new['label'], t('"label" change is saved'));
     $this->assertEqual($instance['description'], $instance_new['description'], t('"description" change is saved'));
@@ -2083,12 +2100,12 @@ class FieldInstanceCrudTestCase extends 
     $this->assertEqual($instance['display']['full']['weight'], $instance_new['display']['full']['weight'], t('Widget weight change is saved'));
 
     // Check that changing widget and formatter types updates the default settings.
-    $instance = field_read_instance($this->instance_definition['field_name'], $this->instance_definition['bundle']);
+    $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
     $instance['widget']['type'] = 'test_field_widget_multiple';
     $instance['display']['full']['type'] = 'field_test_multiple';
     field_update_instance($instance);
 
-    $instance_new = field_read_instance($this->instance_definition['field_name'], $this->instance_definition['bundle']);
+    $instance_new = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
     $this->assertEqual($instance['widget']['type'], $instance_new['widget']['type'] , t('Widget type change is saved.'));
     $settings = field_info_widget_settings($instance_new['widget']['type']);
     $this->assertIdentical($settings, array_intersect_key($instance_new['widget']['settings'], $settings) , t('Widget type change updates default settings.'));
@@ -2098,11 +2115,11 @@ class FieldInstanceCrudTestCase extends 
     $this->assertIdentical($settings, array_intersect_key($instance_new['display']['full']['settings'], $settings) , t('Changing formatter type updates default settings.'));
 
     // Check that adding a new build mode is saved and gets default settings.
-    $instance = field_read_instance($this->instance_definition['field_name'], $this->instance_definition['bundle']);
+    $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
     $instance['display']['teaser'] = array();
     field_update_instance($instance);
 
-    $instance_new = field_read_instance($this->instance_definition['field_name'], $this->instance_definition['bundle']);
+    $instance_new = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
     $this->assertTrue(isset($instance_new['display']['teaser']), t('Display for the new build_mode has been written.'));
     $this->assertIdentical($instance_new['display']['teaser']['type'], $field_type['default_formatter'], t('Default formatter for the new build_mode has been written.'));
     $info = field_info_formatter_types($instance_new['display']['teaser']['type']);
@@ -2128,21 +2145,21 @@ class FieldInstanceCrudTestCase extends 
     $instance = field_create_instance($this->another_instance_definition);
 
     // Test that the first instance is not deleted, and then delete it.
-    $instance = field_read_instance($this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE));
+    $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE));
     $this->assertTrue(!empty($instance) && empty($instance['deleted']), t('A new field instance is not marked for deletion.'));
     field_delete_instance($instance);
 
     // Make sure the instance is marked as deleted when the instance is
     // specifically loaded.
-    $instance = field_read_instance($this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE));
+    $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE));
     $this->assertTrue(!empty($instance['deleted']), t('A deleted field instance is marked for deletion.'));
 
     // Try to load the instance normally and make sure it does not show up.
-    $instance = field_read_instance($this->instance_definition['field_name'], $this->instance_definition['bundle']);
+    $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
     $this->assertTrue(empty($instance), t('A deleted field instance is not loaded by default.'));
 
     // Make sure the other field instance is not deleted.
-    $another_instance = field_read_instance($this->another_instance_definition['field_name'], $this->another_instance_definition['bundle']);
+    $another_instance = field_read_instance('test_entity', $this->another_instance_definition['field_name'], $this->another_instance_definition['bundle']);
     $this->assertTrue(!empty($another_instance) && empty($another_instance['deleted']), t('A non-deleted field instance is not marked for deletion.'));
   }
 }
@@ -2184,6 +2201,7 @@ class FieldTranslationsTestCase extends 
 
     $instance = array(
       'field_name' => $this->field_name,
+      'object_type' => $this->obj_type,
       'bundle' => 'test_bundle',
       'label' => $this->randomName() . '_label',
       'description' => $this->randomName() . '_description',
@@ -2200,7 +2218,7 @@ class FieldTranslationsTestCase extends 
       ),
     );
     field_create_instance($instance);
-    $this->instance = field_read_instance($this->field_name, 'test_bundle');
+    $this->instance = field_read_instance('test_entity', $this->field_name, 'test_bundle');
 
     for ($i = 0; $i < 3; ++$i) {
       locale_inc_callback('locale_add_language', 'l' . $i, $this->randomString(), $this->randomString());
@@ -2452,6 +2470,7 @@ class FieldBulkDeleteTestCase extends Fi
       foreach ($this->fields as $field) {
         $instance = array(
           'field_name' => $field['field_name'],
+          'object_type' => $this->entity_type,
           'bundle' => $bundle,
           'widget' => array(
             'type' => 'test_field_widget',
@@ -2490,7 +2509,7 @@ class FieldBulkDeleteTestCase extends Fi
     $this->assertEqual(count($found['test_entity']), 10, 'Correct number of objects found before deleting');
 
     // Delete the instance.
-    $instance = field_info_instance($field['field_name'], $bundle);
+    $instance = field_info_instance($this->entity_type, $field['field_name'], $bundle);
     field_delete_instance($instance);
 
     // The instance still exists, deleted.
@@ -2523,7 +2542,7 @@ class FieldBulkDeleteTestCase extends Fi
     $field = reset($this->fields);
 
     // Delete the instance.
-    $instance = field_info_instance($field['field_name'], $bundle);
+    $instance = field_info_instance($this->entity_type, $field['field_name'], $bundle);
     field_delete_instance($instance);
 
     // No field hooks were called.
@@ -2579,7 +2598,7 @@ class FieldBulkDeleteTestCase extends Fi
 
     foreach ($this->bundles as $bundle) {
       // Delete the instance.
-      $instance = field_info_instance($field['field_name'], $bundle);
+      $instance = field_info_instance($this->entity_type, $field['field_name'], $bundle);
       field_delete_instance($instance);
 
       // Purge the data.
Index: modules/field/modules/field_sql_storage/field_sql_storage.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/field_sql_storage/field_sql_storage.module,v
retrieving revision 1.26
diff -u -F^[fc] -r1.26 field_sql_storage.module
--- modules/field/modules/field_sql_storage/field_sql_storage.module	30 Sep 2009 12:26:36 -0000	1.26
+++ modules/field/modules/field_sql_storage/field_sql_storage.module	10 Oct 2009 12:42:01 -0000
@@ -436,7 +436,7 @@ function field_sql_storage_field_storage
   list($id, $vid, $bundle) = field_extract_ids($obj_type, $object);
   $etid = _field_sql_storage_etid($obj_type);
 
-  foreach (field_info_instances($bundle) as $instance) {
+  foreach (field_info_instances($obj_type, $bundle) as $instance) {
     if (isset($fields[$instance['field_id']])) {
       $field = field_info_field_by_id($instance['field_id']);
       field_sql_storage_field_storage_purge($obj_type, $object, $field, $instance);
@@ -609,15 +609,18 @@ function field_sql_storage_field_storage
  * This function simply marks for deletion all data associated with the field.
  */
 function field_sql_storage_field_storage_delete_instance($instance) {
+  $etid = _field_sql_storage_etid($instance['object_type']);
   $field = field_info_field($instance['field_name']);
   $table_name = _field_sql_storage_tablename($field);
   $revision_name = _field_sql_storage_revision_tablename($field);
   db_update($table_name)
     ->fields(array('deleted' => 1))
+    ->condition('etid', $etid)
     ->condition('bundle', $instance['bundle'])
     ->execute();
   db_update($revision_name)
     ->fields(array('deleted' => 1))
+    ->condition('etid', $etid)
     ->condition('bundle', $instance['bundle'])
     ->execute();
 }
@@ -625,9 +628,10 @@ function field_sql_storage_field_storage
 /**
  * Implement hook_field_attach_rename_bundle().
  */
-function field_sql_storage_field_attach_rename_bundle($bundle_old, $bundle_new) {
+function field_sql_storage_field_attach_rename_bundle($obj_type, $bundle_old, $bundle_new) {
+  $etid = _field_sql_storage_etid($obj_type);
   // We need to account for deleted or inactive fields and instances.
-  $instances = field_read_instances(array('bundle' => $bundle_new), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
+  $instances = field_read_instances(array('object_type' => $obj_type, 'bundle' => $bundle_new), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
   foreach ($instances as $instance) {
     $field = field_info_field_by_id($instance['field_id']);
     if ($field['storage']['type'] == 'field_sql_storage') {
@@ -635,10 +639,12 @@ function field_sql_storage_field_attach_
       $revision_name = _field_sql_storage_revision_tablename($field);
       db_update($table_name)
         ->fields(array('bundle' => $bundle_new))
+        ->condition('etid', $etid)
         ->condition('bundle', $bundle_old)
         ->execute();
       db_update($revision_name)
         ->fields(array('bundle' => $bundle_new))
+        ->condition('etid', $etid)
         ->condition('bundle', $bundle_old)
         ->execute();
     }
Index: modules/field/modules/field_sql_storage/field_sql_storage.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/field_sql_storage/field_sql_storage.test,v
retrieving revision 1.10
diff -u -F^[fc] -r1.10 field_sql_storage.test
--- modules/field/modules/field_sql_storage/field_sql_storage.test	30 Sep 2009 12:26:36 -0000	1.10
+++ modules/field/modules/field_sql_storage/field_sql_storage.test	10 Oct 2009 12:42:01 -0000
@@ -28,6 +28,7 @@ class FieldSqlStorageTestCase extends Dr
     $this->field = field_create_field($this->field);
     $this->instance = array(
       'field_name' => $this->field_name,
+      'object_type' => 'test_entity',
       'bundle' => 'test_bundle'
     );
     $this->instance = field_create_instance($this->instance);
@@ -302,7 +303,7 @@ class FieldSqlStorageTestCase extends Dr
     // Create a decimal 5.2 field and add some data.
     $field = array('field_name' => 'decimal52', 'type' => 'number_decimal', 'settings' => array('precision' => 5, 'scale' => 2));
     $field = field_create_field($field);
-    $instance = array('field_name' => 'decimal52', 'bundle' => FIELD_TEST_BUNDLE);
+    $instance = array('field_name' => 'decimal52', 'object_type' => 'test_entity', 'bundle' => FIELD_TEST_BUNDLE);
     $instance = field_create_instance($instance);
     $entity = field_test_create_stub_entity(0, 0, $instance['bundle']);
     $entity->decimal52[FIELD_LANGUAGE_NONE][0]['value'] = '1.235';
@@ -330,7 +331,7 @@ class FieldSqlStorageTestCase extends Dr
       $field_name = 'testfield';
       $field = array('field_name' => $field_name, 'type' => 'text');
       $field = field_create_field($field);
-      $instance = array('field_name' => $field_name, 'bundle' => FIELD_TEST_BUNDLE);
+      $instance = array('field_name' => $field_name, 'object_type' => 'test_entity', 'bundle' => FIELD_TEST_BUNDLE);
       $instance = field_create_instance($instance);
       $tables = array(_field_sql_storage_tablename($field), _field_sql_storage_revision_tablename($field));
 
Index: modules/field/modules/number/number.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/number/number.module,v
retrieving revision 1.21
diff -u -F^[fc] -r1.21 number.module
--- modules/field/modules/number/number.module	9 Oct 2009 00:59:57 -0000	1.21
+++ modules/field/modules/number/number.module	10 Oct 2009 12:42:01 -0000
@@ -253,7 +253,7 @@ function theme_field_formatter_number_un
 function theme_field_formatter_number($variables) {
   $element = $variables['element'];
   $field = field_info_field($element['#field_name']);
-  $instance = field_info_instance($element['#field_name'], $element['#bundle']);
+  $instance = field_info_instance($element['#object_type'], $element['#field_name'], $element['#bundle']);
   $value = $element['#item']['value'];
   $settings = $element['#settings'];
   $formatter_type = $element['#formatter'];
@@ -368,7 +368,7 @@ function number_field_widget_error($elem
 function number_elements_process($element, $form_state, $form) {
   $field_name = $element['#field_name'];
   $field = field_info_field($element['#field_name']);
-  $instance = field_info_instance($element['#field_name'], $element['#bundle']);
+  $instance = field_info_instance($element['#object_type'], $element['#field_name'], $element['#bundle']);
   $field_key  = $element['#columns'][0];
 
   $value = isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : '';
@@ -390,6 +390,7 @@ function number_elements_process($elemen
     '#description' => $element['#description'],
     '#required' => $element['#required'],
     '#field_name' => $element['#field_name'],
+    '#object_type' => $element['#object_type'],
     '#bundle' => $element['#bundle'],
     '#delta' => $element['#delta'],
     '#columns' => $element['#columns'],
@@ -428,7 +429,7 @@ function number_elements_process($elemen
  */
 function number_float_validate($element, &$form_state) {
   $field = field_info_field($element['#field_name']);
-  $instance = field_info_instance($element['#field_name'], $element['#bundle']);
+  $instance = field_info_instance($element['#object_type'], $element['#field_name'], $element['#bundle']);
   $field_key = $element['#columns'][0];
   $value = $element['#value'][$field_key];
 
@@ -450,7 +451,7 @@ function number_float_validate($element,
  */
 function number_integer_validate($element, &$form_state) {
   $field = field_info_field($element['#field_name']);
-  $instance = field_info_instance($element['#field_name'], $element['#bundle']);
+  $instance = field_info_instance($element['#object_type'], $element['#field_name'], $element['#bundle']);
   $field_key = $element['#columns'][0];
   $value = $element['#value'][$field_key];
 
@@ -472,7 +473,7 @@ function number_integer_validate($elemen
  */
 function number_decimal_validate($element, &$form_state) {
   $field = field_info_field($element['#field_name']);
-  $instance = field_info_instance($element['#field_name'], $element['#bundle']);
+  $instance = field_info_instance($element['#object_type'], $element['#field_name'], $element['#bundle']);
   $field_key = $element['#columns'][0];
   $value = $element['#value'][$field_key];
 
Index: modules/field/modules/options/options.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/options/options.module,v
retrieving revision 1.11
diff -u -F^[fc] -r1.11 options.module
--- modules/field/modules/options/options.module	9 Oct 2009 00:59:57 -0000	1.11
+++ modules/field/modules/options/options.module	10 Oct 2009 12:42:01 -0000
@@ -284,8 +284,8 @@ function options_validate($element, &$fo
 function options_data2form($element, $items, $field) {
   $field_key  = $element['#columns'][0];
   $field = field_info_field($element['#field_name']);
-  $instance = field_info_instance($element['#field_name'], $element['#bundle']);
-  $options    = options_options($field, $instance);
+  $instance = field_info_instance($element['#object_type'], $element['#field_name'], $element['#bundle']);
+  $options = options_options($field, $instance);
 
   $items_transposed = options_transpose_array_rows_cols($items);
   $values = (isset($items_transposed[$field_key]) && is_array($items_transposed[$field_key])) ? $items_transposed[$field_key] : array();
@@ -312,7 +312,7 @@ function options_data2form($element, $it
 function options_form2data($element, $field) {
   $field_key = $element['#columns'][0];
   $field = field_info_field($element['#field_name']);
-  $instance = field_info_instance($element['#field_name'], $element['#bundle']);
+  $instance = field_info_instance($element['#object_type'], $element['#field_name'], $element['#bundle']);
   $items = (array) $element[$field_key]['#value'];
   $options = options_options($field, $instance);
 
Index: modules/field/modules/text/text.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/text/text.module,v
retrieving revision 1.31
diff -u -F^[fc] -r1.31 text.module
--- modules/field/modules/text/text.module	9 Oct 2009 00:59:57 -0000	1.31
+++ modules/field/modules/text/text.module	10 Oct 2009 12:42:01 -0000
@@ -318,7 +318,7 @@ function theme_field_formatter_text_plai
 function theme_field_formatter_text_trimmed($variables) {
   $element = $variables['element'];
   $field = field_info_field($element['#field_name']);
-  $instance = field_info_instance($element['#field_name'], $element['#bundle']);
+  $instance = field_info_instance($element['#object_type'], $element['#field_name'], $element['#bundle']);
   return text_summary($element['#item']['safe'], $instance['settings']['text_processing'] ? $element['#item']['format'] : NULL);
 }
 
@@ -331,7 +331,7 @@ function theme_field_formatter_text_trim
 function theme_field_formatter_text_summary_or_trimmed($variables) {
   $element = $variables['element'];
   $field = field_info_field($element['#field_name']);
-  $instance = field_info_instance($element['#field_name'], $element['#bundle']);
+  $instance = field_info_instance($element['#object_type'], $element['#field_name'], $element['#bundle']);
 
   if (!empty($element['#item']['safe_summary'])) {
     return $element['#item']['safe_summary'];
Index: modules/field/modules/text/text.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/text/text.test,v
retrieving revision 1.12
diff -u -F^[fc] -r1.12 text.test
--- modules/field/modules/text/text.test	20 Sep 2009 09:37:09 -0000	1.12
+++ modules/field/modules/text/text.test	10 Oct 2009 12:42:01 -0000
@@ -40,6 +40,7 @@ class TextFieldTestCase extends DrupalWe
     field_create_field($this->field);
     $this->instance = array(
       'field_name' => $this->field['field_name'],
+      'object_type' => 'test_entity',
       'bundle' => FIELD_TEST_BUNDLE,
       'widget' => array(
         'type' => 'text_textfield',
@@ -85,6 +86,7 @@ class TextFieldTestCase extends DrupalWe
     field_create_field($this->field);
     $this->instance = array(
       'field_name' => $this->field_name,
+      'object_type' => 'test_entity',
       'bundle' => FIELD_TEST_BUNDLE,
       'label' => $this->randomName() . '_label',
       'settings' => array(
@@ -138,6 +140,7 @@ class TextFieldTestCase extends DrupalWe
     field_create_field($this->field);
     $this->instance = array(
       'field_name' => $this->field_name,
+      'object_type' => 'test_entity',
       'bundle' => FIELD_TEST_BUNDLE,
       'label' => $this->randomName() . '_label',
       'settings' => array(
Index: modules/field_ui/field_ui.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field_ui/field_ui.module,v
retrieving revision 1.9
diff -u -F^[fc] -r1.9 field_ui.module
--- modules/field_ui/field_ui.module	9 Oct 2009 21:10:20 -0000	1.9
+++ modules/field_ui/field_ui.module	10 Oct 2009 12:42:01 -0000
@@ -67,7 +67,7 @@ function field_ui_menu() {
         $items["$path/fields/%field_ui_menu"] = array(
           'title callback' => 'field_ui_menu_label',
           'title arguments' => array($instance_position),
-          'load arguments' => array($bundle_arg),
+          'load arguments' => array($obj_type, $bundle_arg),
           'page callback' => 'drupal_get_form',
           'page arguments' => array('field_ui_field_edit_form', $obj_type, $bundle_arg, $instance_position),
           'type' => MENU_LOCAL_TASK,
@@ -75,7 +75,7 @@ function field_ui_menu() {
         ) + $access;
         $items["$path/fields/%field_ui_menu/edit"] = array(
           'title' => 'Edit instance settings',
-          'load arguments' => array($bundle_arg),
+          'load arguments' => array($obj_type, $bundle_arg),
           'page callback' => 'drupal_get_form',
           'page arguments' => array('field_ui_field_edit_form', $obj_type, $bundle_arg, $instance_position),
           'type' => MENU_DEFAULT_LOCAL_TASK,
@@ -83,7 +83,7 @@ function field_ui_menu() {
         ) + $access;
         $items["$path/fields/%field_ui_menu/field-settings"] = array(
           'title' => 'Edit field settings',
-          'load arguments' => array($bundle_arg),
+          'load arguments' => array($obj_type, $bundle_arg),
           'page callback' => 'drupal_get_form',
           'page arguments' => array('field_ui_field_settings_form', $obj_type, $bundle_arg, $instance_position),
           'type' => MENU_LOCAL_TASK,
@@ -91,7 +91,7 @@ function field_ui_menu() {
         ) + $access;
         $items["$path/fields/%field_ui_menu/widget-type"] = array(
           'title' => 'Change widget type',
-          'load arguments' => array($bundle_arg),
+          'load arguments' => array($obj_type, $bundle_arg),
           'page callback' => 'drupal_get_form',
           'page arguments' => array('field_ui_widget_type_form', $obj_type, $bundle_arg, $instance_position),
           'type' => MENU_LOCAL_TASK,
@@ -99,7 +99,7 @@ function field_ui_menu() {
         ) + $access;
         $items["$path/fields/%field_ui_menu/delete"] = array(
           'title' => 'Delete instance',
-          'load arguments' => array($bundle_arg),
+          'load arguments' => array($obj_type, $bundle_arg),
           'page callback' => 'drupal_get_form',
           'page arguments' => array('field_ui_field_delete_form', $obj_type, $bundle_arg, $instance_position),
           'type' => MENU_LOCAL_TASK,
@@ -134,8 +134,8 @@ function field_ui_menu() {
 /**
  * Menu loader; Load a field instance based on its name.
  */
-function field_ui_menu_load($field_name, $bundle_name) {
-  if ($instance = field_info_instance($field_name, $bundle_name)) {
+function field_ui_menu_load($field_name, $obj_type, $bundle_name) {
+  if ($instance = field_info_instance($obj_type, $field_name, $bundle_name)) {
     return $instance;
   }
   return FALSE;
Index: modules/file/file.field.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/file/file.field.inc,v
retrieving revision 1.5
diff -u -F^[fc] -r1.5 file.field.inc
--- modules/file/file.field.inc	9 Oct 2009 00:59:58 -0000	1.5
+++ modules/file/file.field.inc	10 Oct 2009 12:42:01 -0000
@@ -517,6 +517,7 @@ function file_field_widget(&$form, &$for
     // Add extra Field properties.
     '#field_name' => $field['field_name'],
     '#bundle' => $instance['bundle'],
+    '#object_type' => $instance['object_type'],
   );
 
   if ($field['cardinality'] == 1) {
@@ -648,7 +649,7 @@ function file_field_widget_process($elem
   $item['fid'] = $element['fid']['#value'];
 
   $field = field_info_field($element['#field_name']);
-  $instance = field_info_instance($element['#field_name'], $element['#bundle']);
+  $instance = field_info_instance($element['#object_type'], $element['#field_name'], $element['#bundle']);
   $settings = $instance['widget']['settings'];
 
   $element['#theme'] = 'file_widget';
Index: modules/file/tests/file.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/file/tests/file.test,v
retrieving revision 1.3
diff -u -F^[fc] -r1.3 file.test
--- modules/file/tests/file.test	9 Oct 2009 00:59:58 -0000	1.3
+++ modules/file/tests/file.test	10 Oct 2009 12:42:01 -0000
@@ -57,6 +57,7 @@ class FileFieldTestCase extends DrupalWe
 
     $instance = array(
       'field_name' => $field['field_name'],
+      'object_type' => 'node',
       'label' => $name,
       'bundle' => $type_name,
       'required' => !empty($instance_settings['required']),
@@ -76,7 +77,7 @@ class FileFieldTestCase extends DrupalWe
    */
   function updateFileField($name, $type_name, $instance_settings = array(), $widget_settings = array()) {
     $field = field_info_field($name);
-    $instance = field_info_instance($name, $type_name);
+    $instance = field_info_instance('node', $name, $type_name);
     $instance['settings'] = array_merge($instance['settings'], $instance_settings);
     $instance['widget']['settings'] = array_merge($instance['widget']['settings'], $widget_settings);
 
@@ -200,7 +201,7 @@ class FileFieldRevisionTestCase extends 
     $field_name = 'field_' . strtolower($this->randomName());
     $this->createFileField($field_name, $type_name);
     $field = field_info_field($field_name);
-    $instance = field_info_instance($field_name, $type_name);
+    $instance = field_info_instance('node', $field_name, $type_name);
 
     $test_file = $this->getTestFile('text');
 
@@ -293,7 +294,7 @@ class FileFieldDisplayTestCase extends F
     );
     $this->createFileField($field_name, $type_name, $field_settings, $instance_settings, $widget_settings);
     $field = field_info_field($field_name);
-    $instance = field_info_instance($field_name, $type_name);
+    $instance = field_info_instance('node', $field_name, $type_name);
 
     $test_file = $this->getTestFile('text');
 
@@ -339,7 +340,7 @@ class FileFieldValidateTestCase extends 
     $field_name = 'field_' . strtolower($this->randomName());
     $this->createFileField($field_name, $type_name, array(), array('required' => '1'));
     $field = field_info_field($field_name);
-    $instance = field_info_instance($field_name, $type_name);
+    $instance = field_info_instance('node', $field_name, $type_name);
 
     $test_file = $this->getTestFile('text');
 
@@ -384,7 +385,7 @@ class FileFieldValidateTestCase extends 
     $field_name = 'field_' . strtolower($this->randomName());
     $this->createFileField($field_name, $type_name, array(), array('required' => '1'));
     $field = field_info_field($field_name);
-    $instance = field_info_instance($field_name, $type_name);
+    $instance = field_info_instance('node', $field_name, $type_name);
 
     $small_file = $this->getTestFile('text', 131072); // 128KB.
     $large_file = $this->getTestFile('text', 1310720); // 1.2MB
@@ -399,7 +400,7 @@ class FileFieldValidateTestCase extends 
     foreach ($sizes as $max_filesize => $file_limit) {
       // Set the max file upload size.
       $this->updateFileField($field_name, $type_name, array('max_filesize' => $max_filesize));
-      $instance = field_info_instance($field_name, $type_name);
+      $instance = field_info_instance('node', $field_name, $type_name);
 
       // Create a new node with the small file, which should pass.
       $nid = $this->uploadNodeFile($small_file, $field_name, $type_name);
@@ -436,7 +437,7 @@ class FileFieldValidateTestCase extends 
     $field_name = 'field_' . strtolower($this->randomName());
     $this->createFileField($field_name, $type_name);
     $field = field_info_field($field_name);
-    $instance = field_info_instance($field_name, $type_name);
+    $instance = field_info_instance('node', $field_name, $type_name);
 
     // Get the test file (a GIF image).
     $test_file = $this->getTestFile('image');
Index: modules/forum/forum.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.install,v
retrieving revision 1.36
diff -u -F^[fc] -r1.36 forum.install
--- modules/forum/forum.install	8 Oct 2009 07:58:45 -0000	1.36
+++ modules/forum/forum.install	10 Oct 2009 12:42:01 -0000
@@ -43,6 +43,7 @@ function forum_enable() {
 
     $instance = array(
       'field_name' => 'taxonomy_' . $vocabulary->machine_name,
+      'object_type' => 'node',
       'label' => $vocabulary->name,
       'bundle' => 'forum',
       'widget' => array(
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1144
diff -u -F^[fc] -r1.1144 node.module
--- modules/node/node.module	9 Oct 2009 16:33:13 -0000	1.1144
+++ modules/node/node.module	10 Oct 2009 12:42:01 -0000
@@ -510,7 +510,7 @@ function node_type_save($info) {
       ->execute();
 
     if (!empty($type->old_type) && $type->old_type != $type->type) {
-      field_attach_rename_bundle($type->old_type, $type->type);
+      field_attach_rename_bundle('node', $type->old_type, $type->type);
     }
     node_configure_fields($type);
     module_invoke_all('node_type_update', $type);
@@ -522,7 +522,7 @@ function node_type_save($info) {
       ->fields($fields)
       ->execute();
 
-    field_attach_create_bundle($type->type);
+    field_attach_create_bundle('node', $type->type);
     node_configure_fields($type);
     module_invoke_all('node_type_insert', $type);
     $status = SAVED_NEW;
@@ -547,7 +547,7 @@ function node_type_save($info) {
 function node_configure_fields($type) {
    // Add or remove the body field, as needed.
   $field = field_info_field('body');
-  $instance = field_info_instance('body', $type->type);
+  $instance = field_info_instance('node', 'body', $type->type);
   if ($type->has_body) {
     if (empty($field)) {
       $field = array(
@@ -559,6 +559,7 @@ function node_configure_fields($type) {
     if (empty($instance)) {
       $instance = array(
         'field_name' => 'body',
+        'object_type' => 'node',
         'bundle' => $type->type,
         'label' => $type->body_label,
         'widget_type' => 'text_textarea_with_summary',
@@ -587,7 +588,6 @@ function node_configure_fields($type) {
   elseif (!empty($instance)) {
     field_delete_instance($instance);
   }
-
 }
 
 /**
Index: modules/node/node.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.test,v
retrieving revision 1.46
diff -u -F^[fc] -r1.46 node.test
--- modules/node/node.test	2 Oct 2009 14:39:43 -0000	1.46
+++ modules/node/node.test	10 Oct 2009 12:42:02 -0000
@@ -865,7 +865,7 @@ class NodeTypeTestCase extends DrupalWeb
     $web_user = $this->drupalCreateUser(array('bypass node access', 'administer content types'));
     $this->drupalLogin($web_user);
 
-    $instance = field_info_instance('body', 'page');
+    $instance = field_info_instance('node', 'body', 'page');
     $this->assertEqual($instance['label'], 'Body', t('Body field was found.'));
 
     // Verify that title and body fields are displayed.
@@ -881,7 +881,7 @@ class NodeTypeTestCase extends DrupalWeb
     $this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type'));
     field_info_cache_clear();
 
-    $this->assertFalse(field_info_instance('body', 'page'), t('Body field was removed.'));
+    $this->assertFalse(field_info_instance('node', 'body', 'page'), t('Body field was removed.'));
     $this->drupalGet('node/add/page');
     $this->assertRaw('Foo', t('New title label was displayed.'));
     $this->assertNoRaw('Title', t('Old title label was not displayed.'));
@@ -897,7 +897,7 @@ class NodeTypeTestCase extends DrupalWeb
     $this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type'));
     field_info_cache_clear();
 
-    $instance = field_info_instance('body', 'bar');
+    $instance = field_info_instance('node', 'body', 'bar');
     $this->assertEqual($instance['label'], 'Baz', t('Body field was added.'));
     $this->drupalGet('node/add');
     $this->assertRaw('Bar', t('New name was displayed.'));
Index: modules/simpletest/tests/field_test.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/field_test.module,v
retrieving revision 1.28
diff -u -F^[fc] -r1.28 field_test.module
--- modules/simpletest/tests/field_test.module	9 Oct 2009 01:00:03 -0000	1.28
+++ modules/simpletest/tests/field_test.module	10 Oct 2009 12:42:02 -0000
@@ -101,18 +101,21 @@ function field_test_entity_info_alter(&$
 /**
  * Create a new bundle for test_entity objects.
  *
- * @param $bundle_name
+ * @param $bundle
  *   The machine-readable name of the bundle.
  * @param $text
  *   The human-readable name of the bundle. If none is provided, the machine
  *   name will be used.
  */
-function field_test_create_bundle($bundle_name, $text = NULL) {
+function field_test_create_bundle($bundle, $text = NULL) {
   $bundles = variable_get('field_test_bundles', array('test_bundle' => array('label' => 'Test Bundle')));
-  $bundles += array($bundle_name => array('label' => $text ? $text : $bundle_name));
+  $bundles += array($bundle => array('label' => $text ? $text : $bundle));
   variable_set('field_test_bundles', $bundles);
 
-  field_attach_create_bundle($bundle_name);
+  $info = field_test_entity_info();
+  foreach ($info as $type => $type_info) {
+    field_attach_create_bundle($type, $bundle);
+  }
 }
 
 /**
@@ -129,21 +132,27 @@ function field_test_rename_bundle($bundl
   unset($bundles[$bundle_old]);
   variable_set('field_test_bundles', $bundles);
 
-  field_attach_rename_bundle($bundle_old, $bundle_new);
+  $info = field_test_entity_info();
+  foreach ($info as $type => $type_info) {
+    field_attach_rename_bundle($type, $bundle_old, $bundle_new);
+  }
 }
 
 /**
  * Delete a bundle for test_entity objects.
  *
- * @param $bundle_name
+ * @param $bundle
  *   The machine-readable name of the bundle to delete.
  */
-function field_test_delete_bundle($bundle_name) {
+function field_test_delete_bundle($bundle) {
   $bundles = variable_get('field_test_bundles', array('test_bundle' => array('label' => 'Test Bundle')));
-  unset($bundles[$bundle_name]);
+  unset($bundles[$bundle]);
   variable_set('field_test_bundles', $bundles);
 
-  field_attach_delete_bundle($bundle_name);
+  $info = field_test_entity_info();
+  foreach ($info as $type => $type_info) {
+    field_attach_delete_bundle($type, $bundle);
+  }
 }
 
 /**
Index: modules/taxonomy/taxonomy.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.admin.inc,v
retrieving revision 1.72
diff -u -F^[fc] -r1.72 taxonomy.admin.inc
--- modules/taxonomy/taxonomy.admin.inc	9 Oct 2009 01:00:05 -0000	1.72
+++ modules/taxonomy/taxonomy.admin.inc	10 Oct 2009 12:42:02 -0000
@@ -207,7 +207,7 @@ function taxonomy_form_vocabulary_submit
   }
   $vocabulary = (object) $form_state['values'];
   if ($vocabulary->machine_name != $old_vocabulary->machine_name) {
-    field_attach_rename_bundle($old_vocabulary->machine_name, $vocabulary->machine_name);
+    field_attach_rename_bundle('taxonomy_term', $old_vocabulary->machine_name, $vocabulary->machine_name);
   }
   switch (taxonomy_vocabulary_save($vocabulary)) {
     case SAVED_NEW:
Index: modules/taxonomy/taxonomy.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.install,v
retrieving revision 1.24
diff -u -F^[fc] -r1.24 taxonomy.install
--- modules/taxonomy/taxonomy.install	8 Oct 2009 07:58:47 -0000	1.24
+++ modules/taxonomy/taxonomy.install	10 Oct 2009 12:42:02 -0000
@@ -256,7 +256,7 @@ function taxonomy_update_7002() {
       ->fields(array('machine_name' => 'vocabulary_' . $vid))
       ->condition('vid', $vid)
       ->execute();
-    field_attach_create_bundle($machine_name);
+    field_attach_create_bundle('taxonomy_term', $machine_name);
   }
 }
 
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.515
diff -u -F^[fc] -r1.515 taxonomy.module
--- modules/taxonomy/taxonomy.module	9 Oct 2009 01:00:05 -0000	1.515
+++ modules/taxonomy/taxonomy.module	10 Oct 2009 12:42:02 -0000
@@ -299,7 +299,7 @@ function taxonomy_vocabulary_save($vocab
   }
   elseif (empty($vocabulary->vid)) {
     $status = drupal_write_record('taxonomy_vocabulary', $vocabulary);
-    field_attach_create_bundle($vocabulary->machine_name);
+    field_attach_create_bundle('taxonomy_term', $vocabulary->machine_name);
     taxonomy_vocabulary_create_field($vocabulary);
     module_invoke_all('taxonomy_vocabulary_insert', $vocabulary);
   }
@@ -329,7 +329,7 @@ function taxonomy_vocabulary_delete($vid
     taxonomy_term_delete($tid);
   }
 
-  field_attach_delete_bundle($vocabulary['machine_name']);
+  field_attach_delete_bundle('taxonomy_term', $vocabulary['machine_name']);
   module_invoke_all('taxonomy', 'delete', 'vocabulary', $vocabulary);
 
   cache_clear_all();
Index: modules/taxonomy/taxonomy.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.test,v
retrieving revision 1.48
diff -u -F^[fc] -r1.48 taxonomy.test
--- modules/taxonomy/taxonomy.test	8 Oct 2009 07:58:47 -0000	1.48
+++ modules/taxonomy/taxonomy.test	10 Oct 2009 12:42:02 -0000
@@ -665,7 +665,6 @@ class TaxonomyTermFieldTestCase extends 
 
     $web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content', 'administer taxonomy'));
     $this->drupalLogin($web_user);
-
     $this->vocabulary = $this->createVocabulary();
   }
 
@@ -691,6 +690,7 @@ class TaxonomyTermFieldTestCase extends 
     field_create_field($this->field);
     $this->instance = array(
       'field_name' => $this->field_name,
+      'object_type' => 'test_entity',
       'bundle' => FIELD_TEST_BUNDLE,
       'widget' => array(
         'type' => 'options_select',
@@ -749,6 +749,7 @@ class TaxonomyTermFieldTestCase extends 
     field_create_field($this->field);
     $this->instance = array(
       'field_name' => $this->field_name,
+      'object_type' => 'test_entity',
       'bundle' => FIELD_TEST_BUNDLE,
       'label' => $this->randomName() . '_label',
       'widget' => array(
Index: profiles/default/default.install
===================================================================
RCS file: /cvs/drupal/drupal/profiles/default/default.install,v
retrieving revision 1.9
diff -u -F^[fc] -r1.9 default.install
--- profiles/default/default.install	8 Oct 2009 07:58:47 -0000	1.9
+++ profiles/default/default.install	10 Oct 2009 12:42:02 -0000
@@ -187,6 +187,7 @@ function default_install() {
   taxonomy_vocabulary_save($vocabulary);
   $instance = array(
     'field_name' => 'taxonomy_' . $vocabulary->machine_name,
+    'object_type' => 'taxonomy_term',
     'label' => $vocabulary->name,
     'bundle' => 'article',
     'description' => $vocabulary->help,
