Commit 7562a8ef authored by webchick's avatar webchick
Browse files

#707724 by chx: Rename confusing arguments in field/entity APIs.

parent 52195a6b
This diff is collapsed.
This diff is collapsed.
......@@ -41,7 +41,7 @@
* - field_name (string)
* The name of the field. Each field name is unique within Field API.
* When a field is attached to an object, the field's data is stored
* in $object->$field_name.
* in $entity->$field_name.
* - type (string)
* The type of the field, such as 'text' or 'image'. Field types
* are defined by modules that implement hook_field_info().
......@@ -553,9 +553,9 @@ 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 $obj_type => $bundles) {
foreach ($field['bundles'] as $entity_type => $bundles) {
foreach ($bundles as $bundle) {
$instance = field_info_instance($obj_type, $field_name, $bundle);
$instance = field_info_instance($entity_type, $field_name, $bundle);
field_delete_instance($instance);
}
}
......@@ -786,7 +786,7 @@ function _field_write_instance($instance, $update = FALSE) {
* This function will not return deleted instances. Use
* field_read_instances() instead for this purpose.
*
* @param $obj_type
* @param $entity_type
* The type of object to which the field is bound.
* @param $field_name
* The field name to read.
......@@ -801,8 +801,8 @@ function _field_write_instance($instance, $update = FALSE) {
* @return
* An instance structure, or FALSE.
*/
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);
function field_read_instance($entity_type, $field_name, $bundle, $include_additional = array()) {
$instances = field_read_instances(array('object_type' => $entity_type, 'field_name' => $field_name, 'bundle' => $bundle), $include_additional);
return $instances ? current($instances) : FALSE;
}
......@@ -984,14 +984,14 @@ function field_purge_batch($batch_size) {
$field = field_info_field_by_id($instance['field_id']);
// Retrieve some pseudo-objects.
$obj_types = field_attach_query($instance['field_id'], array(array('bundle', $instance['bundle']), array('deleted', 1)), array('limit' => $batch_size));
$entity_types = field_attach_query($instance['field_id'], array(array('bundle', $instance['bundle']), array('deleted', 1)), array('limit' => $batch_size));
if (count($obj_types) > 0) {
if (count($entity_types) > 0) {
// Field data for the instance still exists.
foreach ($obj_types as $obj_type => $objects) {
field_attach_load($obj_type, $objects, FIELD_LOAD_CURRENT, array('field_id' => $field['id'], 'deleted' => 1));
foreach ($entity_types as $entity_type => $entities) {
field_attach_load($entity_type, $entities, FIELD_LOAD_CURRENT, array('field_id' => $field['id'], 'deleted' => 1));
foreach ($objects as $id => $object) {
foreach ($entities as $id => $entity) {
// field_attach_query() may return more results than we asked for.
// Stop when he have done our batch size.
if ($batch_size-- <= 0) {
......@@ -999,7 +999,7 @@ function field_purge_batch($batch_size) {
}
// Purge the data for the object.
field_purge_data($obj_type, $object, $field, $instance);
field_purge_data($entity_type, $entity, $field, $instance);
}
}
}
......@@ -1027,28 +1027,28 @@ function field_purge_batch($batch_size) {
* to a single field. The object itself is not being deleted, and it is quite
* possible that other field data will remain attached to it.
*
* @param $obj_type
* The type of $object; e.g. 'node' or 'user'.
* @param $object
* @param $entity_type
* The type of $entity; e.g. 'node' or 'user'.
* @param $entity
* The pseudo-object whose field data to delete.
* @param $field
* The (possibly deleted) field whose data is being purged.
* @param $instance
* The deleted field instance whose data is being purged.
*/
function field_purge_data($obj_type, $object, $field, $instance) {
function field_purge_data($entity_type, $entity, $field, $instance) {
// Each field type's hook_field_delete() only expects to operate on a single
// field at a time, so we can use it as-is for purging.
$options = array('field_id' => $instance['field_id'], 'deleted' => TRUE);
_field_invoke('delete', $obj_type, $object, $dummy, $dummy, $options);
_field_invoke('delete', $entity_type, $entity, $dummy, $dummy, $options);
// Tell the field storage system to purge the data.
module_invoke($field['storage']['module'], 'field_storage_purge', $obj_type, $object, $field, $instance);
module_invoke($field['storage']['module'], 'field_storage_purge', $entity_type, $entity, $field, $instance);
// Let other modules act on purging the data.
foreach (module_implements('field_attach_purge') as $module) {
$function = $module . '_field_attach_purge';
$function($obj_type, $object, $field, $instance);
$function($entity_type, $entity, $field, $instance);
}
}
......
......@@ -11,7 +11,7 @@
* the corresponding field_attach_[operation]() function.
*/
function field_default_extract_form_values($obj_type, $object, $field, $instance, $langcode, &$items, $form, &$form_state) {
function field_default_extract_form_values($entity_type, $entity, $field, $instance, $langcode, &$items, $form, &$form_state) {
$field_name = $field['field_name'];
if (isset($form_state['values'][$field_name][$langcode])) {
......@@ -29,18 +29,18 @@ function field_default_extract_form_values($obj_type, $object, $field, $instance
*
* @see _hook_field_validate()
*
* @param $obj_type
* The type of $object.
* @param $object
* @param $entity_type
* The type of $entity.
* @param $entity
* The object for the operation.
* @param $field
* The field structure for the operation.
* @param $instance
* The instance structure for $field on $object's bundle.
* The instance structure for $field on $entity's bundle.
* @param $langcode
* The language associated to $items.
* @param $items
* $object->{$field['field_name']}[$langcode], or an empty array if unset.
* $entity->{$field['field_name']}[$langcode], or an empty array if unset.
* @param $errors
* The array of errors, keyed by field name and by value delta, that have
* already been reported for the object. The function should add its errors
......@@ -49,7 +49,7 @@ function field_default_extract_form_values($obj_type, $object, $field, $instance
* - 'error': an error code (should be a string, prefixed with the module name)
* - 'message': the human readable message to be displayed.
*/
function field_default_validate($obj_type, $object, $field, $instance, $langcode, $items, &$errors) {
function field_default_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
// Filter out empty values.
$items = _field_filter_items($field, $items);
......@@ -64,7 +64,7 @@ function field_default_validate($obj_type, $object, $field, $instance, $langcode
}
}
function field_default_submit($obj_type, $object, $field, $instance, $langcode, &$items, $form, &$form_state) {
function field_default_submit($entity_type, $entity, $field, $instance, $langcode, &$items, $form, &$form_state) {
$field_name = $field['field_name'];
// Reorder items to account for drag-n-drop reordering.
......@@ -79,29 +79,29 @@ function field_default_submit($obj_type, $object, $field, $instance, $langcode,
/**
* Default field 'insert' operation.
*
* Insert default value if no $object->$field_name entry was provided.
* Insert default value if no $entity->$field_name entry was provided.
* This can happen with programmatic saves, or on form-based creation where
* the current user doesn't have 'edit' permission for the field.
*/
function field_default_insert($obj_type, $object, $field, $instance, $langcode, &$items) {
// _field_invoke() populates $items with an empty array if the $object has no
// entry for the field, so we check on the $object itself.
function field_default_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
// _field_invoke() populates $items with an empty array if the $entity has no
// entry for the field, so we check on the $entity itself.
// We also check that the current field translation is actually defined before
// assigning it a default value. This way we ensure that only the intended
// languages get a default value. Otherwise we could have default values for
// not yet open languages.
if (empty($object) || !property_exists($object, $field['field_name']) ||
(isset($object->{$field['field_name']}[$langcode]) && count($object->{$field['field_name']}[$langcode]) == 0)) {
$items = field_get_default_value($obj_type, $object, $field, $instance, $langcode);
if (empty($entity) || !property_exists($entity, $field['field_name']) ||
(isset($entity->{$field['field_name']}[$langcode]) && count($entity->{$field['field_name']}[$langcode]) == 0)) {
$items = field_get_default_value($entity_type, $entity, $field, $instance, $langcode);
}
}
/**
* Invokes hook_field_formatter_prepare_view() on the relevant formatters.
*
* @param $obj_type
* The type of $object; e.g. 'node' or 'user'.
* @param $objects
* @param $entity_type
* The type of $entity; e.g. 'node' or 'user'.
* @param $entities
* An array of objects being displayed, keyed by object id.
* @param $field
* The field structure for the operation.
......@@ -118,7 +118,7 @@ function field_default_insert($obj_type, $object, $field, $instance, $langcode,
* - or an array of display settings to use for display, as found in the
* 'display' entry of $instance definitions.
*/
function field_default_prepare_view($obj_type, $objects, $field, $instances, $langcode, &$items, $display) {
function field_default_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $display) {
// Group objects, instances and items by formatter module.
$modules = array();
foreach ($instances as $id => $instance) {
......@@ -126,7 +126,7 @@ function field_default_prepare_view($obj_type, $objects, $field, $instances, $la
if ($display['type'] !== 'hidden') {
$module = $display['module'];
$modules[$module] = $module;
$grouped_objects[$module][$id] = $objects[$id];
$grouped_objects[$module][$id] = $entities[$id];
$grouped_instances[$module][$id] = $instance;
$grouped_displays[$module][$id] = $display;
// hook_field_formatter_prepare_view() alters $items by reference.
......@@ -138,7 +138,7 @@ function field_default_prepare_view($obj_type, $objects, $field, $instances, $la
// Invoke hook_field_formatter_prepare_view().
$function = $module . '_field_formatter_prepare_view';
if (function_exists($function)) {
$function($obj_type, $grouped_objects[$module], $field, $grouped_instances[$module], $langcode, $grouped_items[$module], $grouped_displays[$module]);
$function($entity_type, $grouped_objects[$module], $field, $grouped_instances[$module], $langcode, $grouped_items[$module], $grouped_displays[$module]);
}
}
}
......@@ -146,9 +146,9 @@ function field_default_prepare_view($obj_type, $objects, $field, $instances, $la
/**
* Builds a renderable array for field values.
*
* @param $obj_type
* The type of $object; e.g. 'node' or 'user'.
* @param $objects
* @param $entity_type
* The type of $entity; e.g. 'node' or 'user'.
* @param $entities
* An array of objects being displayed, keyed by object id.
* @param $field
* The field structure for the operation.
......@@ -165,8 +165,8 @@ function field_default_prepare_view($obj_type, $objects, $field, $instances, $la
* - or an array of custom display settings, as found in the 'display' entry
* of $instance definitions.
*/
function field_default_view($obj_type, $object, $field, $instance, $langcode, $items, $display) {
list($id, $vid, $bundle) = entity_extract_ids($obj_type, $object);
function field_default_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
$addition = array();
......@@ -189,23 +189,23 @@ function field_default_view($obj_type, $object, $field, $instance, $langcode, $i
// performance impact on pages with many fields and values.
$function = $display['module'] . '_field_formatter_view';
if (function_exists($function)) {
$elements = $function($obj_type, $object, $field, $instance, $langcode, $items, $display);
$elements = $function($entity_type, $entity, $field, $instance, $langcode, $items, $display);
if ($elements) {
$info = array(
'#theme' => 'field',
'#weight' => $display['weight'],
'#title' => t($instance['label']),
'#access' => field_access('view', $field, $obj_type, $object),
'#access' => field_access('view', $field, $entity_type, $entity),
'#label_display' => $display['label'],
'#view_mode' => $view_mode,
'#language' => $langcode,
'#field_name' => $field['field_name'],
'#field_type' => $field['type'],
'#field_translatable' => $field['translatable'],
'#object_type' => $obj_type,
'#object_type' => $entity_type,
'#bundle' => $bundle,
'#object' => $object,
'#object' => $entity,
'#items' => $items,
'#formatter' => $display['type']
);
......@@ -218,10 +218,10 @@ function field_default_view($obj_type, $object, $field, $instance, $langcode, $i
return $addition;
}
function field_default_prepare_translation($obj_type, $object, $field, $instance, $langcode, &$items) {
function field_default_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items) {
$addition = array();
if (isset($object->translation_source->$field['field_name'])) {
$addition[$field['field_name']] = $object->translation_source->$field['field_name'];
if (isset($entity->translation_source->$field['field_name'])) {
$addition[$field['field_name']] = $entity->translation_source->$field['field_name'];
}
return $addition;
}
......@@ -9,11 +9,11 @@
/**
* Create a separate form element for each field.
*/
function field_default_form($obj_type, $object, $field, $instance, $langcode, $items, &$form, &$form_state, $get_delta = NULL) {
function field_default_form($entity_type, $entity, $field, $instance, $langcode, $items, &$form, &$form_state, $get_delta = NULL) {
// This could be called with no object, as when a UI module creates a
// dummy form to set default values.
if ($object) {
list($id, , ) = entity_extract_ids($obj_type, $object);
if ($entity) {
list($id, , ) = entity_extract_ids($entity_type, $entity);
}
$field_name = $field['field_name'];
......@@ -31,12 +31,12 @@ function field_default_form($obj_type, $object, $field, $instance, $langcode, $i
// Populate widgets with default values when creating a new object.
if (empty($items) && empty($id)) {
$items = field_get_default_value($obj_type, $object, $field, $instance, $langcode);
$items = field_get_default_value($entity_type, $entity, $field, $instance, $langcode);
}
// Collect widget elements.
$elements = array();
if (field_access('edit', $field, $obj_type, $object)) {
if (field_access('edit', $field, $entity_type, $entity)) {
// If field module handles multiple values for this form element, and we
// are displaying an individual element, process the multiple value form.
if (!isset($get_delta) && field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_DEFAULT) {
......@@ -325,7 +325,7 @@ function field_form_element_after_build($element, &$form_state) {
/**
* Transfer field-level validation errors to widgets.
*/
function field_default_form_errors($obj_type, $object, $field, $instance, $langcode, $items, $form, &$form_state) {
function field_default_form_errors($entity_type, $entity, $field, $instance, $langcode, $items, $form, &$form_state) {
$field_name = $field['field_name'];
$field_info = $form_state['field'][$field_name][$langcode];
......
......@@ -208,9 +208,9 @@ function _field_info_collate_fields($reset = FALSE) {
// Populate 'instances'. Only non-deleted instances are considered.
$info['instances'] = array();
foreach (field_info_bundles() as $obj_type => $bundles) {
foreach (field_info_bundles() as $entity_type => $bundles) {
foreach ($bundles as $bundle => $bundle_info) {
$info['instances'][$obj_type][$bundle] = array();
$info['instances'][$entity_type][$bundle] = array();
}
}
foreach ($definitions['instances'] as $instance) {
......@@ -481,19 +481,19 @@ function field_info_storage_types($storage_type = NULL) {
/**
* Returns information about existing bundles.
*
* @param $obj_type
* @param $entity_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,
* An array of bundles for the $entity_type keyed by bundle name,
* or, if no $entity_type was provided, the array of all existing bundles,
* keyed by object type.
*/
function field_info_bundles($obj_type = NULL) {
function field_info_bundles($entity_type = NULL) {
$info = entity_get_info();
if ($obj_type) {
return isset($info[$obj_type]['bundles']) ? $info[$obj_type]['bundles'] : array();
if ($entity_type) {
return isset($info[$entity_type]['bundles']) ? $info[$entity_type]['bundles'] : array();
}
$bundles = array();
......@@ -561,27 +561,27 @@ function field_info_field_by_id($field_id) {
/**
* Retrieves information about field instances.
*
* @param $obj_type
* @param $entity_type
* The object type for which to return instances.
* @param $bundle_name
* The bundle name for which to return instances.
*
* @return
* If $obj_type is not set, return all instances keyed by object type and
* bundle name. If $obj_type is set, return all instances for that object
* type, keyed by bundle name. If $obj_type and $bundle_name are set, return
* If $entity_type is not set, return all instances keyed by object type and
* bundle name. If $entity_type is set, return all instances for that object
* type, keyed by bundle name. If $entity_type and $bundle_name are set, return
* all instances for that bundle.
*/
function field_info_instances($obj_type = NULL, $bundle_name = NULL) {
function field_info_instances($entity_type = NULL, $bundle_name = NULL) {
$info = _field_info_collate_fields();
if (!isset($obj_type)) {
if (!isset($entity_type)) {
return $info['instances'];
}
if (!isset($bundle_name)) {
return $info['instances'][$obj_type];
return $info['instances'][$entity_type];
}
if (isset($info['instances'][$obj_type][$bundle_name])) {
return $info['instances'][$obj_type][$bundle_name];
if (isset($info['instances'][$entity_type][$bundle_name])) {
return $info['instances'][$entity_type][$bundle_name];
}
return array();
}
......@@ -589,17 +589,17 @@ function field_info_instances($obj_type = NULL, $bundle_name = NULL) {
/**
* Returns an array of instance data for a specific field and bundle.
*
* @param $obj_type
* @param $entity_type
* The object type for the instance.
* @param $field_name
* The field name for the instance.
* @param $bundle_name
* The bundle name for the instance.
*/
function field_info_instance($obj_type, $field_name, $bundle_name) {
function field_info_instance($entity_type, $field_name, $bundle_name) {
$info = _field_info_collate_fields();
if (isset($info['instances'][$obj_type][$bundle_name][$field_name])) {
return $info['instances'][$obj_type][$bundle_name][$field_name];
if (isset($info['instances'][$entity_type][$bundle_name][$field_name])) {
return $info['instances'][$entity_type][$bundle_name][$field_name];
}
}
......
......@@ -274,9 +274,9 @@ function field_associate_fields($module) {
/**
* Helper function to get the default value for a field on an object.
*
* @param $obj_type
* The type of $object; e.g. 'node' or 'user'.
* @param $object
* @param $entity_type
* The type of $entity; e.g. 'node' or 'user'.
* @param $entity
* The object for the operation.
* @param $field
* The field structure.
......@@ -285,12 +285,12 @@ function field_associate_fields($module) {
* @param $langcode
* The field language to fill-in with the default value.
*/
function field_get_default_value($obj_type, $object, $field, $instance, $langcode = NULL) {
function field_get_default_value($entity_type, $entity, $field, $instance, $langcode = NULL) {
$items = array();
if (!empty($instance['default_value_function'])) {
$function = $instance['default_value_function'];
if (function_exists($function)) {
$items = $function($obj_type, $object, $field, $instance, $langcode);
$items = $function($entity_type, $entity, $field, $instance, $langcode);
}
}
elseif (!empty($instance['default_value'])) {
......@@ -367,14 +367,14 @@ function _field_sort_items_value_helper($a, $b) {
/**
* Registry of pseudo-field components in a given bundle.
*
* @param $obj_type
* The type of $object; e.g. 'node' or 'user'.
* @param $entity_type
* The type of $entity; e.g. 'node' or 'user'.
* @param $bundle
* The bundle name.
* @return
* The array of pseudo-field elements in the bundle.
*/
function field_extra_fields($obj_type, $bundle) {
function field_extra_fields($entity_type, $bundle) {
$info = &drupal_static(__FUNCTION__, array());
if (empty($info)) {
......@@ -384,25 +384,25 @@ function field_extra_fields($obj_type, $bundle) {
// Add saved weights. The array is keyed by object type, bundle and
// element name.
$extra_weights = variable_get('field_extra_weights', array());
foreach ($extra_weights as $obj_type_name => $bundles) {
foreach ($extra_weights as $entity_type_name => $bundles) {
foreach ($bundles as $bundle_name => $weights) {
foreach ($weights as $key => $value) {
if (isset($info[$obj_type_name][$bundle_name][$key])) {
$info[$obj_type_name][$bundle_name][$key]['weight'] = $value;
if (isset($info[$entity_type_name][$bundle_name][$key])) {
$info[$entity_type_name][$bundle_name][$key]['weight'] = $value;
}
}
}
}
}
return isset($info[$obj_type][$bundle]) ? $info[$obj_type][$bundle]: array();
return isset($info[$entity_type][$bundle]) ? $info[$entity_type][$bundle]: array();
}
/**
* Retrieve the user-defined weight for a 'pseudo-field' component.
*
* @param $obj_type
* The type of $object; e.g. 'node' or 'user'.
* @param $entity_type
* The type of $entity; e.g. 'node' or 'user'.
* @param $bundle
* The bundle name.
* @param $pseudo_field
......@@ -411,8 +411,8 @@ function field_extra_fields($obj_type, $bundle) {
* The weight for the 'pseudo-field', respecting the user settings stored by
* field.module.
*/
function field_extra_field_weight($obj_type, $bundle, $pseudo_field) {
$extra = field_extra_fields($obj_type, $bundle);
function field_extra_field_weight($entity_type, $bundle, $pseudo_field) {
$extra = field_extra_fields($entity_type, $bundle);
if (isset($extra[$pseudo_field])) {
return $extra[$pseudo_field]['weight'];
}
......@@ -499,17 +499,17 @@ function _field_filter_xss_display_allowed_tags() {
* It will have been passed through the necessary check_plain() or check_markup()
* functions as necessary.
*/
function field_format($obj_type, $object, $field, $item, $formatter_type = NULL, $formatter_settings = array()) {
function field_format($entity_type, $entity, $field, $item, $formatter_type = NULL, $formatter_settings = array()) {
if (!is_array($field)) {
$field = field_info_field($field);
}
if (field_access('view', $field, $obj_type, $object)) {
if (field_access('view', $field, $entity_type, $entity)) {
$field_type = field_info_field_types($field['type']);
// We need $field, $instance, $obj_type, $object to be able to display a value...
list(, , $bundle) = entity_extract_ids($obj_type, $object);
$instance = field_info_instance($obj_type, $field['field_name'], $bundle);
// We need $field, $instance, $entity_type, $entity to be able to display a value...
list(, , $bundle) = entity_extract_ids($entity_type, $entity);
$instance = field_info_instance($entity_type, $field['field_name'], $bundle);
$display = array(
'type' => $formatter_type ? $formatter_type : $field_type['default_formatter'],
......@@ -523,12 +523,12 @@ function field_format($obj_type, $object, $field, $item, $formatter_type = NULL,
$element = array(
'#theme' => $theme,
'#field_name' => $field['field_name'],
'#object_type' => $obj_type,
'#object_type' => $entity_type,
'#bundle' => $bundle,
'#formatter' => $display['type'],
'#settings' => $display['settings'],
'#object' => $object,
'#object_type' => $obj_type,
'#object' => $entity,
'#object_type' => $entity_type,
'#delta' => isset($item['#delta']) ? $item['#delta'] : NULL,
);
......@@ -539,7 +539,7 @@ function field_format($obj_type, $object, $field, $item, $formatter_type = NULL,
$items = array($item);
$function = $field['module'] . '_field_sanitize';
if (function_exists($function)) {
$function($obj_type, $object, $field, $instance, $items);
$function($entity_type, $entity, $field, $instance, $items);
}
$element['#item'] = $items[0];
......@@ -549,7 +549,7 @@ function field_format($obj_type, $object, $field, $item, $formatter_type = NULL,
$items = $item;
$function = $field['module'] . '_field_sanitize';
if (function_exists($function)) {
$function($obj_type, $object, $field, $instance, $items);
$function($entity_type, $entity, $field, $instance, $items);
}
foreach ($items as $delta => $item) {
......@@ -580,9 +580,9 @@ function field_format($obj_type, $object, $field, $item, $formatter_type = NULL,
* The function takes care of invoking the prepare_view steps. It also respects
* field access permissions.
*
* @param $obj_type
* The type of $object; e.g. 'node' or 'user'.
* @param $object
* @param $entity_type
* The type of $entity; e.g. 'node' or 'user'.
* @param $entity
* The object containing the field to display. Must at least contain the id
* key and the field data to display.
* @param $field_name
......@@ -616,7 +616,7 @@ function field_format($obj_type, $object, $field, $item, $formatter_type = NULL,
* @return
* A renderable array for the field value.
*/
function field_view_field($obj_type, $object, $field_name, $display = array(), $langcode = NULL) {
function field_view_field($entity_type, $entity, $field_name, $display = array(), $langcode = NULL) {
$output = array();
if ($field = field_info_field($field_name)) {
......@@ -627,8 +627,8 @@ function field_view_field($obj_type, $object, $field_name, $display = array(), $
else {
// When using a view mode, make sure we have settings for it, or fall
// back to the 'full' view mode.
list(, , $bundle) = entity_extract_ids($obj_type, $object);
$instance = field_info_instance($obj_type, $field_name, $bundle);
list(, , $bundle) = entity_extract_ids($entity_type, $entity);
$instance = field_info_instance($entity_type, $field_name, $bundle);
if (!isset($instance['display'][$display])) {
$display = 'full';
}
......@@ -638,20 +638,20 @@ function field_view_field($obj_type, $object, $field_name, $display = array(), $
// 'single field' mode, to reuse the language fallback logic.
$options = array('field_name' => $field_name, 'language' => field_multilingual_valid_language($langcode, FALSE));
$null = NULL;
list($id) = entity_extract_ids($obj_type, $object);
list($id) = entity_extract_ids($entity_type, $entity);
// First let the field types do their preparation.
_field_invoke_multiple('prepare_view', $obj_type, array($id => $object), $display, $null, $options);
_field_invoke_multiple('prepare_view', $entity_type, array($id => $entity), $display, $null, $options);
// Then let the formatters do their own specific massaging.
_field_invoke_multiple_default('prepare_view', $obj_type, a