From 3411c4984946a2426d639dc407165be15325dc83 Mon Sep 17 00:00:00 2001
From: Bram Goffings <bramgoffings@gmail.com>
Date: Tue, 7 Aug 2012 22:15:41 +0200
Subject: [PATCH] remove entity_extract_ids

---
 core/modules/entity/entity.module                  | 46 ++--------------------
 core/modules/field/field.api.php                   | 30 ++++++--------
 core/modules/field/field.attach.inc                | 42 +++++++-------------
 core/modules/field/field.default.inc               |  4 +-
 core/modules/field/field.form.inc                  |  4 +-
 core/modules/field/field.module                    |  2 +-
 core/modules/field/field.multilingual.inc          |  3 +-
 .../field_sql_storage/field_sql_storage.module     | 19 ++++-----
 .../modules/options/tests/options_test.module      |  2 +-
 .../modules/field_test/field_test.storage.inc      | 15 +++----
 core/modules/file/file.field.inc                   | 19 +++------
 core/modules/file/tests/file_module_test.module    |  3 +-
 core/modules/rdf/rdf.module                        |  3 +-
 13 files changed, 58 insertions(+), 134 deletions(-)

diff --git a/core/modules/entity/entity.module b/core/modules/entity/entity.module
index 53f5fe4..00355a8 100644
--- a/core/modules/entity/entity.module
+++ b/core/modules/entity/entity.module
@@ -127,44 +127,6 @@ function entity_info_cache_clear() {
 }
 
 /**
- * Extracts ID, revision ID, and bundle name from an entity.
- *
- * @param $entity_type
- *   The entity type; e.g. 'node' or 'user'.
- * @param $entity
- *   The entity from which to extract values.
- *
- * @return
- *   A numerically indexed array (not a hash table) containing these
- *   elements:
- *   - 0: Primary ID of the entity.
- *   - 1: Revision ID of the entity, or NULL if $entity_type is not versioned.
- *   - 2: Bundle name of the entity.
- */
-function entity_extract_ids($entity_type, $entity) {
-  $info = entity_get_info($entity_type);
-
-  // Objects being created might not have id/vid yet.
-  $id = isset($entity->{$info['entity keys']['id']}) ? $entity->{$info['entity keys']['id']} : NULL;
-  $vid = ($info['entity keys']['revision'] && isset($entity->{$info['entity keys']['revision']})) ? $entity->{$info['entity keys']['revision']} : NULL;
-
-  if (!empty($info['entity keys']['bundle'])) {
-    // Explicitly fail for malformed entities missing the bundle property.
-    if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {
-      throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type)));
-    }
-    $bundle = $entity->{$info['entity keys']['bundle']};
-  }
-  else {
-    // The entity type provides no bundle key: assume a single bundle, named
-    // after the entity type.
-    $bundle = $entity_type;
-  }
-
-  return array($id, $vid, $bundle);
-}
-
-/**
  * Loads an entity from the database.
  *
  * @param string $entity_type
@@ -409,12 +371,11 @@ function entity_prepare_view($entity_type, $entities) {
  */
 function entity_uri($entity_type, $entity) {
   $info = entity_get_info($entity_type);
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
 
   // A bundle-specific callback takes precedence over the generic one for the
   // entity type.
-  if (isset($info['bundles'][$bundle]['uri callback'])) {
-    $uri_callback = $info['bundles'][$bundle]['uri callback'];
+  if (isset($info['bundles'][$entity->bundle()]['uri callback'])) {
+    $uri_callback = $info['bundles'][$entity->bundle()]['uri callback'];
   }
   elseif (isset($info['uri callback'])) {
     $uri_callback = $info['uri callback'];
@@ -492,12 +453,11 @@ function entity_form_field_validate($entity_type, $form, &$form_state) {
  */
 function entity_form_submit_build_entity($entity_type, $entity, $form, &$form_state) {
   $info = entity_get_info($entity_type);
-  list(, , $bundle) = entity_extract_ids($entity_type, $entity);
 
   // Copy top-level form values that are not for fields to entity properties,
   // without changing existing entity properties that are not being edited by
   // this form. Copying field values must be done using field_attach_submit().
-  $values_excluding_fields = $info['fieldable'] ? array_diff_key($form_state['values'], field_info_instances($entity_type, $bundle)) : $form_state['values'];
+  $values_excluding_fields = $info['fieldable'] ? array_diff_key($form_state['values'], field_info_instances($entity_type, $entity->bundle())) : $form_state['values'];
   foreach ($values_excluding_fields as $key => $value) {
     $entity->$key = $value;
   }
diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php
index be98e3a..80a6f6a 100644
--- a/core/modules/field/field.api.php
+++ b/core/modules/field/field.api.php
@@ -584,15 +584,14 @@ function hook_field_storage_update_field($field, $prior_field, $has_data) {
  * @see hook_field_update()
  */
 function hook_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) {
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
   foreach ($items as $delta => $item) {
     // For hook_file_references(), remember that this is being deleted.
     $item['file_field_name'] = $field['field_name'];
     // Pass in the ID of the object that is being removed so all references can
     // be counted in hook_file_references().
     $item['file_field_type'] = $entity_type;
-    $item['file_field_id'] = $id;
-    file_field_delete_file($item, $field, $entity_type, $id);
+    $item['file_field_id'] = $entity->id();
+    file_field_delete_file($item, $field, $entity_type, $entity->id());
   }
 }
 
@@ -617,11 +616,10 @@ function hook_field_delete($entity_type, $entity, $field, $instance, $langcode,
  *   $entity->{$field['field_name']}[$langcode], or an empty array if unset.
  */
 function hook_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) {
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
   foreach ($items as $delta => $item) {
     // For hook_file_references, remember that this file is being deleted.
     $item['file_field_name'] = $field['field_name'];
-    if (file_field_delete_file($item, $field, $entity_type, $id)) {
+    if (file_field_delete_file($item, $field, $entity_type, $entity->id())) {
       $items[$delta] = NULL;
     }
   }
@@ -1794,7 +1792,9 @@ function hook_field_storage_load($entity_type, $entities, $age, $fields, $option
  *   array are field IDs.
  */
 function hook_field_storage_write($entity_type, $entity, $op, $fields) {
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
+  $id = $entity->id();
+  $vid = $entity->getRevisionId();
+  $bundle = $entity->bundle();
   if (!isset($vid)) {
     $vid = $id;
   }
@@ -1888,9 +1888,7 @@ function hook_field_storage_write($entity_type, $entity, $op, $fields) {
  *   array are field IDs.
  */
 function hook_field_storage_delete($entity_type, $entity, $fields) {
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-
-  foreach (field_info_instances($entity_type, $bundle) as $instance) {
+  foreach (field_info_instances($entity_type, $entity->bundle()) as $instance) {
     if (isset($fields[$instance['field_id']])) {
       $field = field_info_field_by_id($instance['field_id']);
       field_sql_storage_field_storage_purge($entity_type, $entity, $field, $instance);
@@ -1918,16 +1916,14 @@ function hook_field_storage_delete($entity_type, $entity, $fields) {
  *   array are field IDs.
  */
 function hook_field_storage_delete_revision($entity_type, $entity, $fields) {
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-
-  if (isset($vid)) {
+  if (isset($entity->getRevisionId())) {
     foreach ($fields as $field_id) {
       $field = field_info_field_by_id($field_id);
       $revision_name = _field_sql_storage_revision_tablename($field);
       db_delete($revision_name)
         ->condition('entity_type', $entity_type)
-        ->condition('entity_id', $id)
-        ->condition('revision_id', $vid)
+        ->condition('entity_id', $entity->id())
+        ->condition('revision_id', $entity->getRevisionId())
         ->execute();
     }
   }
@@ -2631,17 +2627,15 @@ function hook_field_storage_purge_field_instance($instance) {
  *   The deleted field instance whose data is being purged.
  */
 function hook_field_storage_purge($entity_type, $entity, $field, $instance) {
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-
   $table_name = _field_sql_storage_tablename($field);
   $revision_name = _field_sql_storage_revision_tablename($field);
   db_delete($table_name)
     ->condition('entity_type', $entity_type)
-    ->condition('entity_id', $id)
+    ->condition('entity_id', $entity->id())
     ->execute();
   db_delete($revision_name)
     ->condition('entity_type', $entity_type)
-    ->condition('entity_id', $id)
+    ->condition('entity_id', $entity->id())
     ->execute();
 }
 
diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc
index e4b28a9..d09b101 100644
--- a/core/modules/field/field.attach.inc
+++ b/core/modules/field/field.attach.inc
@@ -166,8 +166,7 @@ function _field_invoke($op, $entity_type, $entity, &$a = NULL, &$b = NULL, $opti
   $options += $default_options;
 
   // Determine the list of instances to iterate on.
-  list(, , $bundle) = entity_extract_ids($entity_type, $entity);
-  $instances = _field_invoke_get_instances($entity_type, $bundle, $options);
+  $instances = _field_invoke_get_instances($entity_type, $entity->bundle(), $options);
 
   // Iterate through the instances and collect results.
   $return = array();
@@ -279,8 +278,7 @@ function _field_invoke_multiple($op, $entity_type, $entities, &$a = NULL, &$b =
   // $entity->$field_name property.
   foreach ($entities as $entity) {
     // Determine the list of instances to iterate on.
-    list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-    $instances = _field_invoke_get_instances($entity_type, $bundle, $options);
+    $instances = _field_invoke_get_instances($entity_type, $entity->bundle(), $options);
 
     foreach ($instances as $instance) {
       $field_id = $instance['field_id'];
@@ -296,6 +294,7 @@ function _field_invoke_multiple($op, $entity_type, $entities, &$a = NULL, &$b =
         // by hook implementations.
         // Unless a language code suggestion is provided we iterate on all the
         // available language codes.
+        $id = $entity->id();
         $available_langcodes = field_available_languages($entity_type, $field);
         $langcode = !empty($options['langcode'][$id]) ? $options['langcode'][$id] : $options['langcode'];
         $langcodes = _field_language_suggestion($available_langcodes, $langcode, $field_name);
@@ -546,10 +545,9 @@ function field_attach_form($entity_type, $entity, &$form, &$form_state, $langcod
   $form += (array) _field_invoke_default('form', $entity_type, $entity, $form, $form_state, $options);
 
   // Add custom weight handling.
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
   $form['#pre_render'][] = '_field_extra_fields_pre_render';
   $form['#entity_type'] = $entity_type;
-  $form['#bundle'] = $bundle;
+  $form['#bundle'] = $entity->bundle();
 
   // Let other modules make changes to the form.
   // Avoid module_invoke_all() to let parameters be taken by reference.
@@ -658,9 +656,9 @@ function field_attach_load($entity_type, $entities, $age = FIELD_LOAD_CURRENT, $
     // Collect the storage backends used by the remaining fields in the entities.
     $storages = array();
     foreach ($queried_entities as $entity) {
-      list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-      $instances = _field_invoke_get_instances($entity_type, $bundle, $options);
-
+      $instances = _field_invoke_get_instances($entity_type, $entity->bundle(), $options);
+      $id = $entity->id();
+      $vid = $entity->getRevisionId();
       foreach ($instances as $instance) {
         $field_name = $instance['field_name'];
         $field_id = $instance['field_id'];
@@ -694,8 +692,7 @@ function field_attach_load($entity_type, $entities, $age = FIELD_LOAD_CURRENT, $
     if ($cache_write) {
       foreach ($queried_entities as $id => $entity) {
         $data = array();
-        list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-        $instances = field_info_instances($entity_type, $bundle);
+        $instances = field_info_instances($entity_type, $entity->bundle());
         foreach ($instances as $instance) {
           $data[$instance['field_name']] = $queried_entities[$id]->{$instance['field_name']};
         }
@@ -888,8 +885,6 @@ function field_attach_insert($entity_type, $entity) {
   _field_invoke_default('insert', $entity_type, $entity);
   _field_invoke('insert', $entity_type, $entity);
 
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-
   // Let any module insert field data before the storage engine, accumulating
   // saved fields along the way.
   $skip_fields = array();
@@ -900,7 +895,7 @@ function field_attach_insert($entity_type, $entity) {
 
   // Collect the storage backends used by the remaining fields in the entities.
   $storages = array();
-  foreach (field_info_instances($entity_type, $bundle) as $instance) {
+  foreach (field_info_instances($entity_type, $entity->bundle()) as $instance) {
     $field = field_info_field_by_id($instance['field_id']);
     $field_id = $field['id'];
     $field_name = $field['field_name'];
@@ -935,8 +930,6 @@ function field_attach_insert($entity_type, $entity) {
 function field_attach_update($entity_type, $entity) {
   _field_invoke('update', $entity_type, $entity);
 
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-
   // Let any module update field data before the storage engine, accumulating
   // saved fields along the way.
   $skip_fields = array();
@@ -947,7 +940,7 @@ function field_attach_update($entity_type, $entity) {
 
   // Collect the storage backends used by the remaining fields in the entities.
   $storages = array();
-  foreach (field_info_instances($entity_type, $bundle) as $instance) {
+  foreach (field_info_instances($entity_type, $entity->bundle()) as $instance) {
     $field = field_info_field_by_id($instance['field_id']);
     $field_id = $field['id'];
     $field_name = $field['field_name'];
@@ -990,11 +983,9 @@ function field_attach_update($entity_type, $entity) {
 function field_attach_delete($entity_type, $entity) {
   _field_invoke('delete', $entity_type, $entity);
 
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-
   // Collect the storage backends used by the fields in the entities.
   $storages = array();
-  foreach (field_info_instances($entity_type, $bundle) as $instance) {
+  foreach (field_info_instances($entity_type, $entity->bundle()) as $instance) {
     $field = field_info_field_by_id($instance['field_id']);
     $field_id = $field['id'];
     $storages[$field['storage']['type']][$field_id] = $field_id;
@@ -1027,11 +1018,9 @@ function field_attach_delete($entity_type, $entity) {
 function field_attach_delete_revision($entity_type, $entity) {
   _field_invoke('delete_revision', $entity_type, $entity);
 
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-
   // Collect the storage backends used by the fields in the entities.
   $storages = array();
-  foreach (field_info_instances($entity_type, $bundle) as $instance) {
+  foreach (field_info_instances($entity_type, $entity->bundle()) as $instance) {
     $field = field_info_field_by_id($instance['field_id']);
     $field_id = $field['id'];
     $storages[$field['storage']['type']][$field_id] = $field_id;
@@ -1159,10 +1148,9 @@ function field_attach_view($entity_type, $entity, $view_mode, $langcode = NULL)
   $output = _field_invoke_default('view', $entity_type, $entity, $view_mode, $null, $options);
 
   // Add custom weight handling.
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
   $output['#pre_render'][] = '_field_extra_fields_pre_render';
   $output['#entity_type'] = $entity_type;
-  $output['#bundle'] = $bundle;
+  $output['#bundle'] = $entity->bundle();
 
   // Let other modules alter the renderable array.
   $context = array(
@@ -1201,9 +1189,7 @@ function field_attach_view($entity_type, $entity, $view_mode, $langcode = NULL)
  *   values.
  */
 function field_attach_preprocess($entity_type, $entity, $element, &$variables) {
-  list(, , $bundle) = entity_extract_ids($entity_type, $entity);
-
-  foreach (field_info_instances($entity_type, $bundle) as $instance) {
+  foreach (field_info_instances($entity_type, $entity->bundle()) as $instance) {
     $field_name = $instance['field_name'];
     if (isset($element[$field_name]['#language'])) {
       $langcode = $element[$field_name]['#language'];
diff --git a/core/modules/field/field.default.inc b/core/modules/field/field.default.inc
index 1e1675c..b4a6f50 100644
--- a/core/modules/field/field.default.inc
+++ b/core/modules/field/field.default.inc
@@ -189,8 +189,6 @@ function field_default_prepare_view($entity_type, $entities, $field, $instances,
  *     of $instance definitions.
  */
 function field_default_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-
   $addition = array();
 
   // Prepare incoming display specifications.
@@ -222,7 +220,7 @@ function field_default_view($entity_type, $entity, $field, $instance, $langcode,
           '#field_type' => $field['type'],
           '#field_translatable' => $field['translatable'],
           '#entity_type' => $entity_type,
-          '#bundle' => $bundle,
+          '#bundle' => $entity->bundle(),
           '#object' => $entity,
           '#items' => $items,
           '#formatter' => $display['type']
diff --git a/core/modules/field/field.form.inc b/core/modules/field/field.form.inc
index d9a0342..bd81c7c 100644
--- a/core/modules/field/field.form.inc
+++ b/core/modules/field/field.form.inc
@@ -30,7 +30,7 @@
  *   or an empty array to use default values.
  * @param $form
  *   An array representing the form that the editing element will be attached
- *   to. 
+ *   to.
  * @param $form_state
  *   An array containing the current state of the form.
  * @param $get_delta
@@ -43,7 +43,7 @@ function field_default_form($entity_type, $entity, $field, $instance, $langcode,
   // This could be called with no entity, as when a UI module creates a
   // dummy form to set default values.
   if ($entity) {
-    list($id, , ) = entity_extract_ids($entity_type, $entity);
+    $id = $entity->id();
   }
 
   $parents = $form['#parents'];
diff --git a/core/modules/field/field.module b/core/modules/field/field.module
index d42e5ac..8157971 100644
--- a/core/modules/field/field.module
+++ b/core/modules/field/field.module
@@ -910,7 +910,7 @@ function field_view_field($entity_type, $entity, $field_name, $display = array()
 
     // Invoke prepare_view steps if needed.
     if (empty($entity->_field_view_prepared)) {
-      list($id) = entity_extract_ids($entity_type, $entity);
+      $id = $entity->id();
 
       // First let the field types do their preparation.
       _field_invoke_multiple('prepare_view', $entity_type, array($id => $entity), $display, $null, $options);
diff --git a/core/modules/field/field.multilingual.inc b/core/modules/field/field.multilingual.inc
index 533c881..e5e81ce 100644
--- a/core/modules/field/field.multilingual.inc
+++ b/core/modules/field/field.multilingual.inc
@@ -295,7 +295,8 @@ function field_valid_language($langcode, $default = TRUE) {
  */
 function field_language($entity_type, $entity, $field_name = NULL, $langcode = NULL) {
   $display_langcodes = &drupal_static(__FUNCTION__, array());
-  list($id, , $bundle) = entity_extract_ids($entity_type, $entity);
+  $id = $entity->bundle();
+  $bundle = $entity->bundle();
   $langcode = field_valid_language($langcode, FALSE);
 
   if (!isset($display_langcodes[$entity_type][$id][$langcode])) {
diff --git a/core/modules/field/modules/field_sql_storage/field_sql_storage.module b/core/modules/field/modules/field_sql_storage/field_sql_storage.module
index fd2f52c..69e8bda 100644
--- a/core/modules/field/modules/field_sql_storage/field_sql_storage.module
+++ b/core/modules/field/modules/field_sql_storage/field_sql_storage.module
@@ -378,7 +378,9 @@ function field_sql_storage_field_storage_load($entity_type, $entities, $age, $fi
  * Implements hook_field_storage_write().
  */
 function field_sql_storage_field_storage_write($entity_type, $entity, $op, $fields) {
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
+  $vid = $entity->getRevisionId();
+  $id = $entity->id();
+  $bundle = $entity->bundle();
   if (!isset($vid)) {
     $vid = $id;
   }
@@ -463,9 +465,7 @@ function field_sql_storage_field_storage_write($entity_type, $entity, $op, $fiel
  * This function deletes data for all fields for an entity from the database.
  */
 function field_sql_storage_field_storage_delete($entity_type, $entity, $fields) {
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-
-  foreach (field_info_instances($entity_type, $bundle) as $instance) {
+  foreach (field_info_instances($entity_type, $entity->bundle()) as $instance) {
     if (isset($fields[$instance['field_id']])) {
       $field = field_info_field_by_id($instance['field_id']);
       field_sql_storage_field_storage_purge($entity_type, $entity, $field, $instance);
@@ -480,17 +480,15 @@ function field_sql_storage_field_storage_delete($entity_type, $entity, $fields)
  * an entity.
  */
 function field_sql_storage_field_storage_purge($entity_type, $entity, $field, $instance) {
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-
   $table_name = _field_sql_storage_tablename($field);
   $revision_name = _field_sql_storage_revision_tablename($field);
   db_delete($table_name)
     ->condition('entity_type', $entity_type)
-    ->condition('entity_id', $id)
+    ->condition('entity_id', $entity->id())
     ->execute();
   db_delete($revision_name)
     ->condition('entity_type', $entity_type)
-    ->condition('entity_id', $id)
+    ->condition('entity_id', $entity->id())
     ->execute();
 }
 
@@ -655,15 +653,14 @@ function _field_sql_storage_query_field_conditions(EntityFieldQuery $query, Sele
  * This function actually deletes the data from the database.
  */
 function field_sql_storage_field_storage_delete_revision($entity_type, $entity, $fields) {
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-
+  $vid = $entity->getRevisionId();
   if (isset($vid)) {
     foreach ($fields as $field_id) {
       $field = field_info_field_by_id($field_id);
       $revision_name = _field_sql_storage_revision_tablename($field);
       db_delete($revision_name)
         ->condition('entity_type', $entity_type)
-        ->condition('entity_id', $id)
+        ->condition('entity_id', $entity->id())
         ->condition('revision_id', $vid)
         ->execute();
     }
diff --git a/core/modules/field/modules/options/tests/options_test.module b/core/modules/field/modules/options/tests/options_test.module
index e30b1ef..604205b 100644
--- a/core/modules/field/modules/options/tests/options_test.module
+++ b/core/modules/field/modules/options/tests/options_test.module
@@ -28,5 +28,5 @@ function options_test_allowed_values_callback($field, $instance, $entity_type, $
 function options_test_dynamic_values_callback($field, $instance, $entity_type, $entity, &$cacheable) {
   $cacheable = FALSE;
   // We need the values of the entity as keys.
-  return drupal_map_assoc(array_merge(array($entity->ftlabel), entity_extract_ids($entity_type, $entity)));
+  return drupal_map_assoc(array_merge(array($entity->ftlabel), array($entity->id(), $entity->getRevisionId(), $entity->bundle())));
 }
diff --git a/core/modules/field/tests/modules/field_test/field_test.storage.inc b/core/modules/field/tests/modules/field_test/field_test.storage.inc
index b4b98ea..ac4819e 100644
--- a/core/modules/field/tests/modules/field_test/field_test.storage.inc
+++ b/core/modules/field/tests/modules/field_test/field_test.storage.inc
@@ -119,7 +119,9 @@ function field_test_field_storage_load($entity_type, $entities, $age, $fields, $
 function field_test_field_storage_write($entity_type, $entity, $op, $fields) {
   $data = _field_test_storage_data();
 
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
+  $id = $entity->id();
+  $vid = $entity->getVersionId();
+  $bundle = $entity->bundle();
 
   foreach ($fields as $field_id) {
     $field = field_info_field_by_id($field_id);
@@ -187,11 +189,9 @@ function field_test_field_storage_write($entity_type, $entity, $op, $fields) {
  * Implements hook_field_storage_delete().
  */
 function field_test_field_storage_delete($entity_type, $entity, $fields) {
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-
   // Note: reusing field_test_storage_purge(), like field_sql_storage.module
   // does, is highly inefficient in our case...
-  foreach (field_info_instances($bundle) as $instance) {
+  foreach (field_info_instances($entity->bundle()) as $instance) {
     if (isset($fields[$instance['field_id']])) {
       $field = field_info_field_by_id($instance['field_id']);
       field_test_field_storage_purge($entity_type, $entity, $field, $instance);
@@ -205,12 +205,10 @@ function field_test_field_storage_delete($entity_type, $entity, $fields) {
 function field_test_field_storage_purge($entity_type, $entity, $field, $instance) {
   $data = _field_test_storage_data();
 
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-
   $field_data = &$data[$field['id']];
   foreach (array('current', 'revisions') as $sub_table) {
     foreach ($field_data[$sub_table] as $key => $row) {
-      if ($row->type == $entity_type && $row->entity_id == $id) {
+      if ($row->type == $entity_type && $row->entity_id == $entity->id()) {
         unset($field_data[$sub_table][$key]);
       }
     }
@@ -225,12 +223,11 @@ function field_test_field_storage_purge($entity_type, $entity, $field, $instance
 function field_test_field_storage_delete_revision($entity_type, $entity, $fields) {
   $data = _field_test_storage_data();
 
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
   foreach ($fields as $field_id) {
     $field_data = &$data[$field_id];
     foreach (array('current', 'revisions') as $sub_table) {
       foreach ($field_data[$sub_table] as $key => $row) {
-        if ($row->type == $entity_type && $row->entity_id == $id && $row->revision_id == $vid) {
+        if ($row->type == $entity_type && $row->entity_id == $entity->id() && $row->revision_id == $entity->getRevisionId()) {
           unset($field_data[$sub_table][$key]);
         }
       }
diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc
index b331e4b..70314db 100644
--- a/core/modules/file/file.field.inc
+++ b/core/modules/file/file.field.inc
@@ -217,11 +217,9 @@ function file_field_prepare_view($entity_type, $entities, $field, $instances, $l
  * Implements hook_field_insert().
  */
 function file_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-
   // Add a new usage of each uploaded file.
   foreach ($items as $item) {
-    file_usage_add(file_load($item['fid']), 'file', $entity_type, $id);
+    file_usage_add(file_load($item['fid']), 'file', $entity_type, $entity->id());
   }
 }
 
@@ -231,13 +229,11 @@ function file_field_insert($entity_type, $entity, $field, $instance, $langcode,
  * Checks for files that have been removed from the object.
  */
 function file_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) {
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-
   // On new revisions, all files are considered to be a new usage and no
   // deletion of previous file usages are necessary.
   if (!empty($entity->revision)) {
     foreach ($items as $item) {
-      file_usage_add(file_load($item['fid']), 'file', $entity_type, $id);
+      file_usage_add(file_load($item['fid']), 'file', $entity_type, $entity->id());
     }
     return;
   }
@@ -256,7 +252,7 @@ function file_field_update($entity_type, $entity, $field, $instance, $langcode,
       $original_fids[] = $original_item['fid'];
       if (isset($original_item['fid']) && !in_array($original_item['fid'], $current_fids)) {
         // Decrement the file usage count by 1.
-        file_usage_delete(file_load($original_item['fid']), 'file', $entity_type, $id);
+        file_usage_delete(file_load($original_item['fid']), 'file', $entity_type, $entity->id());
       }
     }
   }
@@ -264,7 +260,7 @@ function file_field_update($entity_type, $entity, $field, $instance, $langcode,
   // Add new usage entries for newly added files.
   foreach ($items as $item) {
     if (!in_array($item['fid'], $original_fids)) {
-      file_usage_add(file_load($item['fid']), 'file', $entity_type, $id);
+      file_usage_add(file_load($item['fid']), 'file', $entity_type, $entity->id());
     }
   }
 }
@@ -273,11 +269,9 @@ function file_field_update($entity_type, $entity, $field, $instance, $langcode,
  * Implements hook_field_delete().
  */
 function file_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) {
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-
   // Delete all file usages within this entity.
   foreach ($items as $delta => $item) {
-    file_usage_delete(file_load($item['fid']), 'file', $entity_type, $id, 0);
+    file_usage_delete(file_load($item['fid']), 'file', $entity_type, $entity->id(), 0);
   }
 }
 
@@ -285,10 +279,9 @@ function file_field_delete($entity_type, $entity, $field, $instance, $langcode,
  * Implements hook_field_delete_revision().
  */
 function file_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) {
-  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
   foreach ($items as $delta => $item) {
     // Decrement the file usage count by 1.
-    file_usage_delete(file_load($item['fid']), 'file', $entity_type, $id);
+    file_usage_delete(file_load($item['fid']), 'file', $entity_type, $entity->id());
   }
 }
 
diff --git a/core/modules/file/tests/file_module_test.module b/core/modules/file/tests/file_module_test.module
index 490ef42..216b10f 100644
--- a/core/modules/file/tests/file_module_test.module
+++ b/core/modules/file/tests/file_module_test.module
@@ -73,8 +73,7 @@ function file_module_test_form_submit($form, &$form_state) {
  * Implements hook_file_download_access().
  */
 function file_module_test_file_download_access($field, $entity_type, $entity) {
-  list(,, $bundle) = entity_extract_ids($entity_type, $entity);
-  $instance = field_info_instance($entity_type, $field['field_name'], $bundle);
+  $instance = field_info_instance($entity_type, $field['field_name'], $entity->bundle());
   // Allow the file to be downloaded only if the given arguments are correct.
   // If any are wrong, $instance will be NULL.
   if (empty($instance)) {
diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module
index e3f76d1..f829e47 100644
--- a/core/modules/rdf/rdf.module
+++ b/core/modules/rdf/rdf.module
@@ -395,8 +395,7 @@ function rdf_entity_info_alter(&$entity_info) {
 function rdf_entity_load($entities, $type) {
   foreach ($entities as $entity) {
     // Extracts the bundle of the entity being loaded.
-    list($id, $vid, $bundle) = entity_extract_ids($type, $entity);
-    $entity->rdf_mapping = rdf_mapping_load($type, $bundle);
+    $entity->rdf_mapping = rdf_mapping_load($type, $entity->bundle());
   }
 }
 
-- 
1.7.11.msysgit.1

