Remove autoload functions... crappy!

From: Damien Tournoud <damien@tournoud.net>


---
 theme.inc                                          |    3 
 field/field.attach.inc                             |   89 ++---
 field/field.autoload.inc                           |  372 --------------------
 field/field.crud.inc                               |   10 -
 field/field.default.inc                            |    2 
 field/field.form.inc                               |    4 
 field/field.module                                 |   12 -
 field/field.test                                   |   90 ++---
 .../field_sql_storage/field_sql_storage.module     |    8 
 field/modules/text/text.test                       |   10 -
 node/node.module                                   |   15 -
 node/node.pages.inc                                |    6 
 simpletest/tests/field_test.module                 |   21 +
 user/user.module                                   |   14 -
 user/user.pages.inc                                |    8 
 15 files changed, 138 insertions(+), 526 deletions(-)

diff --git includes/theme.inc includes/theme.inc
index c15abed..968f73e 100644
--- includes/theme.inc
+++ includes/theme.inc
@@ -2023,8 +2023,7 @@ function template_preprocess_node(&$variables) {
   $variables['template_files'][] = 'node-' . $node->nid;
 
   // Add $FIELD_NAME_rendered variables for fields.
-  drupal_function_exists('field_attach_preprocess');
-  $variables += field_attach_preprocess('node', $node);
+  $variables += FieldAttach::preprocess('node', $node);
 }
 
 /**
diff --git modules/field/field.attach.inc modules/field/field.attach.inc
index 4a7b3f9..ee01c63 100644
--- modules/field/field.attach.inc
+++ modules/field/field.attach.inc
@@ -6,14 +6,14 @@
  * Field attach API, allowing objects (nodes, users, ...) to be 'fieldable'.
  */
 
-// TODO D7 : consistency - do field_attach_functions return a value or alter in place ?
+// TODO D7 : consistency - do FieldAttach::functions return a value or alter in place ?
 
 // TODO D7 : consistency - some of these functions process individual fields
 // and others process the combined value of all fields.
 // Should all iteration through available fields be done here instead of in Field?
 
 /**
- * Exception class thrown by field_attach_validate() when field
+ * Exception class thrown by FieldAttach::validate() when field
  * validation errors occur.
  */
 class FieldValidationException extends FieldException {
@@ -73,10 +73,6 @@ define('FIELD_STORAGE_INSERT', 'insert');
  */
 
 /**
- * @autoload field_attach_.* field_attach FieldException {
- */
-
-/**
  * @defgroup field_attach Field Attach API
  * @{
  * Operate on Field API data attached to Drupal objects.
@@ -93,7 +89,7 @@ define('FIELD_STORAGE_INSERT', 'insert');
  * identified by hook_fieldable_info() for $obj_type.
  *
  * Fieldable types call Field Attach API functions during their own
- * API calls; for example, node_load() calls field_attach_load(). A
+ * API calls; for example, node_load() calls FieldAttach::load(). A
  * fieldable type is not required to use all of the Field Attach
  * API functions.
  *
@@ -101,14 +97,14 @@ define('FIELD_STORAGE_INSERT', 'insert');
  * function that allows any module to act on Field Attach operations
  * for any object after the operation is complete, and access or
  * modify all the field, form, or display data for that object and
- * operation. For example, field_attach_view() invokes
- * hook_field_attach_view().  These all-module hooks are distinct from
+ * operation. For example, FieldAttach::view() invokes
+ * hook_FieldAttach::view().  These all-module hooks are distinct from
  * those of the Field Types API, such as hook_field_load(), that are
  * only invoked for the module that defines a specific field type.
  *
- * field_attach_load(), field_attach_insert(), and
- * field_attach_update() also define pre-operation hooks,
- * e.g. hook_field_attach_pre_load().  These hooks run before the
+ * FieldAttach::load(), FieldAttach::insert(), and
+ * FieldAttach::update() also define pre-operation hooks,
+ * e.g. hook_FieldAttach::pre_load().  These hooks run before the
  * corresponding Field Storage API and Field Type API operations.
  * They allow modules to define additional storage locations
  * (e.g. denormalizing, mirroring) for field data on a per-field
@@ -164,7 +160,7 @@ define('FIELD_STORAGE_INSERT', 'insert');
  *  - FALSE: render the field module's implementation of the field hook.
  */
 function _field_invoke($op, $obj_type, &$object, &$a = NULL, &$b = NULL, $default = FALSE) {
-  list(, , $bundle) = field_attach_extract_ids($obj_type, $object);
+  list(, , $bundle) = FieldAttach::extract_ids($obj_type, $object);
   $instances = field_info_instances($bundle);
 
   $return = array();
@@ -201,12 +197,7 @@ function _field_invoke_default($op, $obj_type, &$object, &$a = NULL, &$b = NULL)
   return _field_invoke($op, $obj_type, $object, $a, $b, TRUE);
 }
 
-/**
- * @} End of "defgroup field_attach"
- *
- * The rest of the functions in this file are not in a group, but
- * their automatically-generated autoloaders are (see field.autoload.inc).
- */
+class FieldAttach {
 
 /**
  * Add form elements for all fields for an object to a form structure.
@@ -222,9 +213,9 @@ function _field_invoke_default($op, $obj_type, &$object, &$a = NULL, &$b = NULL)
  *   An associative array containing the current state of the form.
  *
  * TODO : document the resulting $form structure, like we do for
- * field_attach_view().
+ * FieldAttach::view().
  */
-function _field_attach_form($obj_type, $object, &$form, $form_state) {
+static function form($obj_type, $object, &$form, $form_state) {
   // TODO : something's not right here : do we alter the form or return a value ?
   $form += (array) _field_invoke_default('form', $obj_type, $object, $form, $form_state);
 
@@ -250,17 +241,17 @@ function _field_attach_form($obj_type, $object, &$form, $form_state) {
  *   FIELD_LOAD_CURRENT to load the most recent revision for all
  *   fields, or FIELD_LOAD_REVISION to load the version indicated by
  *   each object. Defaults to FIELD_LOAD_CURRENT; use
- *   field_attach_load_revision() instead of passing FIELD_LOAD_REVISION.
+ *   FieldAttach::load_revision() instead of passing FIELD_LOAD_REVISION.
  * @returns
  *   On return, the objects in $objects are modified by having the
  *   appropriate set of fields added.
  */
-function _field_attach_load($obj_type, $objects, $age = FIELD_LOAD_CURRENT) {
+static function load($obj_type, $objects, $age = FIELD_LOAD_CURRENT) {
   $queried_objects = array();
 
   // Fetch avaliable objects from cache.
   foreach ($objects as $object) {
-    list($id, $vid, $bundle, $cacheable) = field_attach_extract_ids($obj_type, $object);
+    list($id, $vid, $bundle, $cacheable) = FieldAttach::extract_ids($obj_type, $object);
     $cid = "field:$obj_type:$id:$vid";
     if ($cacheable && $cached = cache_get($cid, 'cache_field')) {
       foreach ($cached->data as $key => $value) {
@@ -315,7 +306,7 @@ function _field_attach_load($obj_type, $objects, $age = FIELD_LOAD_CURRENT) {
     // multiple objects too. Which forbids going through _field_invoke(), but
     // requires manually iterating the instances instead.
     foreach ($queried_objects as $id => $object) {
-      list($id, $vid, $bundle, $cacheable) = field_attach_extract_ids($obj_type, $object);
+      list($id, $vid, $bundle, $cacheable) = FieldAttach::extract_ids($obj_type, $object);
 
       // Make sure empty fields are present as empty arrays.
       $instances = field_info_instances($bundle);
@@ -368,8 +359,8 @@ function _field_attach_load($obj_type, $objects, $age = FIELD_LOAD_CURRENT) {
  *   On return, the objects in $objects are modified by having the
  *   appropriate set of fields added.
  */
-function _field_attach_load_revision($obj_type, $objects) {
-  return field_attach_load($obj_type, $objects, FIELD_LOAD_REVISION);
+static function load_revision($obj_type, $objects) {
+  return FieldAttach::load($obj_type, $objects, FIELD_LOAD_REVISION);
 }
 
 /**
@@ -387,7 +378,7 @@ function _field_attach_load_revision($obj_type, $objects) {
  * @return
  *   Throws a FieldValidationException if validation errors are found.
  */
-function _field_attach_validate($obj_type, &$object) {
+static function validate($obj_type, &$object) {
   $errors = array();
   _field_invoke_default('validate', $obj_type, $object, $errors);
   _field_invoke('validate', $obj_type, $object, $errors);
@@ -431,13 +422,13 @@ function _field_attach_validate($obj_type, &$object) {
  * @param $form_state
  *   An associative array containing the current state of the form.
  */
-function _field_attach_form_validate($obj_type, &$object, $form, &$form_state) {
+static function form_validate($obj_type, &$object, $form, &$form_state) {
   // Extract field values from submitted values.
   _field_invoke_default('extract_form_values', $obj_type, $object, $form, $form_state);
 
   // Perform field_level validation.
   try {
-    field_attach_validate($obj_type, $object);
+    FieldAttach::validate($obj_type, $object);
   }
   catch (FieldValidationException $e) {
     // Pass field-level validation errors back to widgets for accurate error
@@ -463,7 +454,7 @@ function _field_attach_form_validate($obj_type, &$object, $form, &$form_state) {
  * @param $form_state
  *   An associative array containing the current state of the form.
  */
-function _field_attach_submit($obj_type, &$object, $form, &$form_state) {
+static function submit($obj_type, &$object, $form, &$form_state) {
   // Extract field values from submitted values.
   _field_invoke_default('extract_form_values', $obj_type, $object, $form, $form_state);
 
@@ -487,7 +478,7 @@ function _field_attach_submit($obj_type, &$object, $form, &$form_state) {
  * @param $object
  *   The object with fields to process.
  */
-function _field_attach_presave($obj_type, &$object) {
+static function presave($obj_type, &$object) {
   // TODO : to my knowledge, no field module has any use for 'presave' on D6.
   // should we keep this ?
   _field_invoke('presave', $obj_type, $object);
@@ -508,7 +499,7 @@ function _field_attach_presave($obj_type, &$object) {
  * @param $object
  *   The object with fields to save.
  */
-function _field_attach_insert($obj_type, &$object) {
+static function insert($obj_type, &$object) {
 
   _field_invoke('insert', $obj_type, $object);
 
@@ -523,7 +514,7 @@ function _field_attach_insert($obj_type, &$object) {
   // Field storage module saves any remaining unsaved fields.
   module_invoke(variable_get('field_storage_module', 'field_sql_storage'), 'field_storage_write', $obj_type, $object, FIELD_STORAGE_INSERT, $saved);
 
-  list($id, $vid, $bundle, $cacheable) = field_attach_extract_ids($obj_type, $object);
+  list($id, $vid, $bundle, $cacheable) = FieldAttach::extract_ids($obj_type, $object);
   if ($cacheable) {
     cache_clear_all("field:$obj_type:$id:", 'cache_field', TRUE);
   }
@@ -537,7 +528,7 @@ function _field_attach_insert($obj_type, &$object) {
  * @param $object
  *   The object with fields to save.
  */
-function _field_attach_update($obj_type, &$object) {
+static function update($obj_type, &$object) {
 
   _field_invoke('update', $obj_type, $object);
 
@@ -552,7 +543,7 @@ function _field_attach_update($obj_type, &$object) {
   // Field storage module saves any remaining unsaved fields.
   module_invoke(variable_get('field_storage_module', 'field_sql_storage'), 'field_storage_write', $obj_type, $object, FIELD_STORAGE_UPDATE, $saved);
 
-  list($id, $vid, $bundle, $cacheable) = field_attach_extract_ids($obj_type, $object);
+  list($id, $vid, $bundle, $cacheable) = FieldAttach::extract_ids($obj_type, $object);
   if ($cacheable) {
     cache_clear_all("field:$obj_type:$id:$vid", 'cache_field');
   }
@@ -567,7 +558,7 @@ function _field_attach_update($obj_type, &$object) {
  * @param $object
  *   The object whose field data to delete.
  */
-function _field_attach_delete($obj_type, &$object) {
+static function delete($obj_type, &$object) {
   _field_invoke('delete', $obj_type, $object);
   module_invoke(variable_get('field_storage_module', 'field_sql_storage'), 'field_storage_delete', $obj_type, $object);
 
@@ -577,7 +568,7 @@ function _field_attach_delete($obj_type, &$object) {
     $function($obj_type, $object);
   }
 
-  list($id, $vid, $bundle, $cacheable) = field_attach_extract_ids($obj_type, $object);
+  list($id, $vid, $bundle, $cacheable) = FieldAttach::extract_ids($obj_type, $object);
   if ($cacheable) {
     cache_clear_all("field:$obj_type:$id:", 'cache_field', TRUE);
   }
@@ -592,7 +583,7 @@ function _field_attach_delete($obj_type, &$object) {
  * @param $object
  *   The object with fields to save.
  */
-function _field_attach_delete_revision($obj_type, &$object) {
+static function delete_revision($obj_type, &$object) {
   _field_invoke('delete revision', $obj_type, $object);
   module_invoke(variable_get('field_storage_module', 'field_sql_storage'), 'field_storage_delete_revision', $obj_type, $object);
 
@@ -602,7 +593,7 @@ function _field_attach_delete_revision($obj_type, &$object) {
     $function($obj_type, $object);
   }
 
-  list($id, $vid, $bundle, $cacheable) = field_attach_extract_ids($obj_type, $object);
+  list($id, $vid, $bundle, $cacheable) = FieldAttach::extract_ids($obj_type, $object);
   if ($cacheable) {
     cache_clear_all("field:$obj_type:$id:$vid", 'cache_field');
   }
@@ -623,7 +614,7 @@ function _field_attach_delete_revision($obj_type, &$object) {
  * @return
  *   A structured content array tree for drupal_render().
  */
-function _field_attach_view($obj_type, &$object, $teaser = FALSE) {
+static function view($obj_type, &$object, $teaser = FALSE) {
   // Let field modules sanitize their data for output.
   _field_invoke('sanitize', $obj_type, $object);
 
@@ -646,7 +637,7 @@ function _field_attach_view($obj_type, &$object, $teaser = FALSE) {
  *   containing the themed output for the whole field.
  * - Adds the formatted values in the 'view' key of the items.
  */
-function _field_attach_preprocess($obj_type, &$object) {
+static function preprocess($obj_type, &$object) {
   return _field_invoke_default('preprocess', $obj_type, $object);
 }
 
@@ -655,7 +646,7 @@ function _field_attach_preprocess($obj_type, &$object) {
  *
  * TODO D7: We do not yet know if this really belongs in Field API.
  */
-function _field_attach_prepare_translation(&$node) {
+static function prepare_translation(&$node) {
   // Prevent against invalid 'nodes' built by broken 3rd party code.
   if (isset($node->type)) {
     $type = content_types($node->type);
@@ -679,7 +670,7 @@ function _field_attach_prepare_translation(&$node) {
  * @param $bundle
  *   The name of the newly created bundle.
  */
-function _field_attach_create_bundle($bundle) {
+static function create_bundle($bundle) {
   module_invoke(variable_get('field_storage_module', 'field_sql_storage'), 'field_storage_create_bundle', $bundle);
 
   // Clear the cache.
@@ -699,7 +690,7 @@ function _field_attach_create_bundle($bundle) {
  * @param $bundle_new
  *   The new name of the bundle.
  */
-function _field_attach_rename_bundle($bundle_old, $bundle_new) {
+static function rename_bundle($bundle_old, $bundle_new) {
   module_invoke(variable_get('field_storage_module', 'field_sql_storage'), 'field_storage_rename_bundle', $bundle_old, $bundle_new);
   db_update('field_config_instance')
     ->fields(array('bundle' => $bundle_new))
@@ -728,7 +719,7 @@ function _field_attach_rename_bundle($bundle_old, $bundle_new) {
  * @param $bundle
  *   The bundle to delete.
  */
-function _field_attach_delete_bundle($bundle) {
+static function delete_bundle($bundle) {
   // Let other modules act on deleting the bundle
   foreach (module_implements('field_attach_delete_bundle') as $module) {
     $function = $module . '_field_attach_delete_bundle';
@@ -758,7 +749,7 @@ function _field_attach_delete_bundle($bundle) {
  *   2: bundle name of the object
  *   3: whether $obj_type's fields should be cached (TRUE/FALSE)
  */
-function _field_attach_extract_ids($object_type, $object) {
+static function extract_ids($object_type, $object) {
   // TODO D7 : prevent against broken 3rd party $node without 'type'.
   $info = field_info_fieldable_types($object_type);
   // Objects being created might not have id/vid yet.
@@ -771,6 +762,4 @@ function _field_attach_extract_ids($object_type, $object) {
   return array($id, $vid, $bundle, $cacheable);
 }
 
-/**
- * @autoload} End of "@autoload field_attach"
- */
+}
diff --git modules/field/field.autoload.inc modules/field/field.autoload.inc
index ed7e08c..15574cb 100644
--- modules/field/field.autoload.inc
+++ modules/field/field.autoload.inc
@@ -2,378 +2,6 @@
 // $Id: field.autoload.inc,v 1.6 2009-03-26 13:31:24 webchick Exp $
 
 /**
- * DO NOT EDIT THIS FILE.  It contains autoloading functions generated
- * automatically by generate-autoload.pl.  The function names,
- * arguments, and PHPdoc are copied from the file that defines the
- * underlying function. To edit them, edit the underlying file instead.
- */
-
-/**
- * @ingroup field_attach
- * @{
- */
-
-/**
- * Add form elements for all fields for an object to a form structure.
- *
- * @param $obj_type
- *   The type of $object; e.g. 'node' or 'user'.
- * @param $object
- *   The object for which to load form elements, used to initialize
- *   default form values.
- * @param $form
- *   The form structure to fill in.
- * @param $form_state
- *   An associative array containing the current state of the form.
- *
- * TODO : document the resulting $form structure, like we do for
- * field_attach_view().
- *
- * This function is an autoloader for _field_attach_form() in modules/field/field.attach.inc.
- */
-function field_attach_form($obj_type, $object, &$form, $form_state) {
-  require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
-  return _field_attach_form($obj_type, $object, $form, $form_state);
-}
-
-/**
- * Load all fields for the most current version of each of a set of
- * objects of a single object type.
- *
- * @param $obj_type
- *   The type of objects for which to load fields; e.g. 'node' or
- *   'user'.
- * @param $objects
- *   An array of objects for which to load fields. The keys for
- *   primary id and bundle name to load are identified by
- *   hook_fieldable_info for $obj_type.
- * @param $age
- *   FIELD_LOAD_CURRENT to load the most recent revision for all
- *   fields, or FIELD_LOAD_REVISION to load the version indicated by
- *   each object. Defaults to FIELD_LOAD_CURRENT; use
- *   field_attach_load_revision() instead of passing FIELD_LOAD_REVISION.
- * @returns
- *   On return, the objects in $objects are modified by having the
- *   appropriate set of fields added.
- *
- * This function is an autoloader for _field_attach_load() in modules/field/field.attach.inc.
- */
-function field_attach_load($obj_type, $objects, $age = FIELD_LOAD_CURRENT) {
-  require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
-  return _field_attach_load($obj_type, $objects, $age);
-}
-
-/**
- * Load all fields for a previous version of each of a set of
- * objects of a single object type.
- *
- * @param $obj_type
- *   The type of objects for which to load fields; e.g. 'node' or
- *   'user'.
- * @param $objects
- *   An array of objects for which to load fields. The keys for
- *   primary id, revision id, and bundle name to load are identified by
- *   hook_fieldable_info for $obj_type.
- * @returns
- *   On return, the objects in $objects are modified by having the
- *   appropriate set of fields added.
- *
- * This function is an autoloader for _field_attach_load_revision() in modules/field/field.attach.inc.
- */
-function field_attach_load_revision($obj_type, $objects) {
-  require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
-  return _field_attach_load_revision($obj_type, $objects);
-}
-
-/**
- * Perform field validation against the field data in an object.
- *
- * This function does not perform field widget validation on form
- * submissions. It is intended to be called during API save
- * operations. Use field_attach_form_validate() to validate form
- * submissions.
- *
- * @param $obj_type
- *   The type of $object; e.g. 'node' or 'user'.
- * @param $object
- *   The object with fields to validate.
- * @return
- *   Throws a FieldValidationException if validation errors are found.
- *
- * This function is an autoloader for _field_attach_validate() in modules/field/field.attach.inc.
- */
-function field_attach_validate($obj_type, &$object) {
-  require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
-  return _field_attach_validate($obj_type, $object);
-}
-
-/**
- * Perform field validation against form-submitted field values.
- *
- * There are two levels of validation for fields in forms: widget
- * validation, and field validation.
- * - Widget validation steps are specific to a given widget's own form
- * structure and UI metaphors. They are executed through FAPI's
- * #element_validate property during normal form validation.
- * - Field validation steps are common to a given field type, independently of
- * the specific widget being used in a given form. They are defined in the
- * field type's implementation of hook_field_validate().
- *
- * This function performs field validation in the context of a form
- * submission. It converts field validation errors into form errors
- * on the correct form elements. Fieldable object types should call
- * this function during their own form validation function.
- *
- * @param $obj_type
- *   The type of $object; e.g. 'node' or 'user'.
- * @param $object
- *   The object being submitted. The 'bundle key', 'id key' and (if applicable)
- *   'revision key' should be present. The actual field values will be read
- *   from $form_state['values'].
- * @param $form
- *   The form structure.
- * @param $form_state
- *   An associative array containing the current state of the form.
- *
- * This function is an autoloader for _field_attach_form_validate() in modules/field/field.attach.inc.
- */
-function field_attach_form_validate($obj_type, &$object, $form, &$form_state) {
-  require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
-  return _field_attach_form_validate($obj_type, $object, $form, $form_state);
-}
-
-/**
- * Perform necessary operations on field data submitted by a form.
- *
- * Currently, this accounts for drag-and-drop reordering of
- * field values, and filtering of empty values.
- *
- * @param $obj_type
- *   The type of $object; e.g. 'node' or 'user'.
- * @param $object
- *   The object being submitted. The 'bundle key', 'id key' and (if applicable)
- *   'revision key' should be present. The actual field values will be read
- *   from $form_state['values'].
- * @param $form
- *   The form structure to fill in.
- * @param $form_state
- *   An associative array containing the current state of the form.
- *
- * This function is an autoloader for _field_attach_submit() in modules/field/field.attach.inc.
- */
-function field_attach_submit($obj_type, &$object, $form, &$form_state) {
-  require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
-  return _field_attach_submit($obj_type, $object, $form, $form_state);
-}
-
-/**
- * Perform necessary operations just before fields data get saved.
- *
- * We take no specific action here, we just give other
- * modules the opportunity to act.
- *
- * @param $obj_type
- *   The type of $object; e.g. 'node' or 'user'.
- * @param $object
- *   The object with fields to process.
- *
- * This function is an autoloader for _field_attach_presave() in modules/field/field.attach.inc.
- */
-function field_attach_presave($obj_type, &$object) {
-  require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
-  return _field_attach_presave($obj_type, $object);
-}
-
-/**
- * Save field data for a new object. The passed in object must
- * already contain its id and (if applicable) revision id attributes.
- *
- * @param $obj_type
- *   The type of $object; e.g. 'node' or 'user'.
- * @param $object
- *   The object with fields to save.
- *
- * This function is an autoloader for _field_attach_insert() in modules/field/field.attach.inc.
- */
-function field_attach_insert($obj_type, &$object) {
-  require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
-  return _field_attach_insert($obj_type, $object);
-}
-
-/**
- * Save field data for an existing object.
- *
- * @param $obj_type
- *   The type of $object; e.g. 'node' or 'user'.
- * @param $object
- *   The object with fields to save.
- *
- * This function is an autoloader for _field_attach_update() in modules/field/field.attach.inc.
- */
-function field_attach_update($obj_type, &$object) {
-  require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
-  return _field_attach_update($obj_type, $object);
-}
-
-/**
- * Delete field data for an existing object. This deletes all
- * revisions of field data for the object.
- *
- * @param $obj_type
- *   The type of $object; e.g. 'node' or 'user'.
- * @param $object
- *   The object whose field data to delete.
- *
- * This function is an autoloader for _field_attach_delete() in modules/field/field.attach.inc.
- */
-function field_attach_delete($obj_type, &$object) {
-  require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
-  return _field_attach_delete($obj_type, $object);
-}
-
-/**
- * Delete field data for a single revision of an existing object. The
- * passed object must have a revision id attribute.
- *
- * @param $obj_type
- *   The type of $object; e.g. 'node' or 'user'.
- * @param $object
- *   The object with fields to save.
- *
- * This function is an autoloader for _field_attach_delete_revision() in modules/field/field.attach.inc.
- */
-function field_attach_delete_revision($obj_type, &$object) {
-  require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
-  return _field_attach_delete_revision($obj_type, $object);
-}
-
-/**
- * Generate and return a structured content array tree suitable for
- * drupal_render() for all of the fields on an object. The format of
- * each field's rendered content depends on the display formatter and
- * its settings.
- *
- * @param $obj_type
- *   The type of $object; e.g. 'node' or 'user'.
- * @param $object
- *   The object with fields to render.
- * @param $teaser
- *   Whether to display the teaser only, as on the main page.
- * @return
- *   A structured content array tree for drupal_render().
- *
- * This function is an autoloader for _field_attach_view() in modules/field/field.attach.inc.
- */
-function field_attach_view($obj_type, &$object, $teaser = FALSE) {
-  require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
-  return _field_attach_view($obj_type, $object, $teaser);
-}
-
-/**
- * To be called in entity preprocessor.
- *
- * - Adds $FIELD_NAME_rendered variables
- *   containing the themed output for the whole field.
- * - Adds the formatted values in the 'view' key of the items.
- *
- * This function is an autoloader for _field_attach_preprocess() in modules/field/field.attach.inc.
- */
-function field_attach_preprocess($obj_type, &$object) {
-  require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
-  return _field_attach_preprocess($obj_type, $object);
-}
-
-/**
- * Implementation of hook_node_prepare_translation.
- *
- * TODO D7: We do not yet know if this really belongs in Field API.
- *
- * This function is an autoloader for _field_attach_prepare_translation() in modules/field/field.attach.inc.
- */
-function field_attach_prepare_translation(&$node) {
-  require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
-  return _field_attach_prepare_translation($node);
-}
-
-/**
- * Notify field.module that a new bundle was created.
- *
- * The default SQL-based storage doesn't need to do anytrhing about it, but
- * others might.
- *
- * @param $bundle
- *   The name of the newly created bundle.
- *
- * This function is an autoloader for _field_attach_create_bundle() in modules/field/field.attach.inc.
- */
-function field_attach_create_bundle($bundle) {
-  require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
-  return _field_attach_create_bundle($bundle);
-}
-
-/**
- * Notify field.module that a bundle was renamed.
- *
- * @param $bundle_old
- *   The previous name of the bundle.
- * @param $bundle_new
- *   The new name of the bundle.
- *
- * This function is an autoloader for _field_attach_rename_bundle() in modules/field/field.attach.inc.
- */
-function field_attach_rename_bundle($bundle_old, $bundle_new) {
-  require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
-  return _field_attach_rename_bundle($bundle_old, $bundle_new);
-}
-
-/**
- * Notify field.module the a bundle was deleted.
- *
- * This deletes the data for the field instances as well as the field instances
- * themselves. This function actually just marks the data and field instances
- * and deleted, leaving the garbage collection for a separate process, because
- * it is not always possible to delete this much data in a single page request
- * (particularly since for some field types, the deletion is more than just a
- * simple DELETE query).
- *
- * @param $bundle
- *   The bundle to delete.
- *
- * This function is an autoloader for _field_attach_delete_bundle() in modules/field/field.attach.inc.
- */
-function field_attach_delete_bundle($bundle) {
-  require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
-  return _field_attach_delete_bundle($bundle);
-}
-
-/**
- * Helper function to extract id, vid, and bundle name from an object.
- *
- * @param $obj_type
- *   The type of $object; e.g. 'node' or 'user'.
- * @param $object
- *   The object from which to extract values.
- * @return
- *   A numerically indexed array (not a hash table) containing these
- *   elements:
- *
- *   0: primary id of the object
- *   1: revision id of the object, or NULL if $obj_type is not versioned
- *   2: bundle name of the object
- *   3: whether $obj_type's fields should be cached (TRUE/FALSE)
- *
- * This function is an autoloader for _field_attach_extract_ids() in modules/field/field.attach.inc.
- */
-function field_attach_extract_ids($object_type, $object) {
-  require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
-  return _field_attach_extract_ids($object_type, $object);
-}
-
-/**
- * @} End of "field_attach"
- */
-
-/**
  * @ingroup field_info
  * @{
  */
diff --git modules/field/field.crud.inc modules/field/field.crud.inc
index c1f114f..72d4080 100644
--- modules/field/field.crud.inc
+++ modules/field/field.crud.inc
@@ -26,7 +26,7 @@
  * 'photo' to the bundle 'article'. When the node system uses the
  * Field Attach API to load all fields for an Article node, it passes
  * the node's content type (which is 'article') as the node's bundle.
- * field_attach_load() then loads the 'subtitle' and 'photo' fields
+ * FieldAttach::load() then loads the 'subtitle' and 'photo' fields
  * because they are both attached to the bundle 'article'.
  *
  * Field objects are (currently) represented as an array of key/value
@@ -94,16 +94,16 @@
  * - weight (float)
  *     The order in which the field should be sorted relative
  *     to other fields when used with this bundle. The weight affects
- *     ordering in both forms (see field_attach_form()) and rendered output
- *     (see field_attach_view()).
+ *     ordering in both forms (see FieldAttach::form()) and rendered output
+ *     (see FieldAttach::view()).
  *     TODO - this should probably become a context setting so that
  *     the weight can be different in the form and in various other
  *     contexts.
  * - required (integer)
  *     TRUE if a value for this field is required when used with this
  *     bundle, FALSE otherwise. Currently, required-ness is only enforced
- *     during Form API operations, not by field_attach_load(),
- *     field_attach_insert(), or field_attach_update().
+ *     during Form API operations, not by FieldAttach::load(),
+ *     FieldAttach::insert(), or FieldAttach::update().
  * - default_value_function (string)
  *     The name of the function, if any, that will provide a default value.
  * - deleted (integer, read-only)
diff --git modules/field/field.default.inc modules/field/field.default.inc
index d7d309c..58caee3 100644
--- modules/field/field.default.inc
+++ modules/field/field.default.inc
@@ -104,7 +104,7 @@ function field_default_submit($obj_type, &$object, $field, $instance, &$items, $
  *   );
  */
 function field_default_view($obj_type, $object, $field, $instance, $items, $teaser) {
-  list($id, $vid, $bundle) = field_attach_extract_ids($obj_type, $object);
+  list($id, $vid, $bundle) = FieldAttach::extract_ids($obj_type, $object);
 
   $addition = array();
 
diff --git modules/field/field.form.inc modules/field/field.form.inc
index 89aa846..d27cefb 100644
--- modules/field/field.form.inc
+++ modules/field/field.form.inc
@@ -15,7 +15,7 @@ function field_default_form($obj_type, $object, $field, $instance, $items, &$for
   // This could be called with no object, as when a UI module creates a
   // dummy form to set default values.
   if ($object) {
-    list($id, ,) = field_attach_extract_ids($obj_type, $object);
+    list($id, ,) = FieldAttach::extract_ids($obj_type, $object);
   }
   $addition = array();
 
@@ -23,7 +23,7 @@ function field_default_form($obj_type, $object, $field, $instance, $items, &$for
 
   // If the field is not accessible, don't add anything. The field value will
   // be left unchanged on update, or considered empty on insert.
-  // TODO : if/when field_attach_insert() takes care of default values,
+  // TODO : if/when FieldAttach::insert() takes care of default values,
   // unaccessible fields will automatically get the default value on insert.
   if (!field_access('edit', $field)) {
     return $addition;
diff --git modules/field/field.module modules/field/field.module
index ad548d8..4570043 100644
--- modules/field/field.module
+++ modules/field/field.module
@@ -69,12 +69,12 @@ define('FIELD_BEHAVIOR_CUSTOM', 0x0004);
 
 /**
  * Age argument for loading the most recent version of an object's
- * field data with field_attach_load().
+ * field data with FieldAttach::load().
  */
 define('FIELD_LOAD_CURRENT', 'FIELD_LOAD_CURRENT');
 /**
  * Age argument for loading the version of an object's field data
- * specified in the object with field_attach_load().
+ * specified in the object with FieldAttach::load().
  */
 define('FIELD_LOAD_REVISION', 'FIELD_LOAD_REVISION');
 
@@ -150,7 +150,7 @@ function field_theme() {
     // TODO D7 : do we need exclude in core? See [#367215].
     // This is just adding '#post_render' => array('field_wrapper_post_render')
     // at the right places in the render array generated by field_default_view().
-    // Can be done in hook_field_attach_post_view if we want.
+    // Can be done in hook_FieldAttach::post_view if we want.
     'field_exclude' => array(
       'arguments' => array('content' => NULL, 'object' => array(), 'context' => NULL),
     ),
@@ -398,7 +398,7 @@ function field_format($obj_type, $object, $field, $item, $formatter_name = NULL,
 
   if (field_access('view', $field)) {
     // Basically, we need $field, $instance, $obj_type, $object to be able to display a value...
-    list(, , $bundle) = field_attach_extract_ids($obj_type, $object);
+    list(, , $bundle) = FieldAttach::extract_ids($obj_type, $object);
     $instance = field_info_instance($field['field_name'], $bundle);
 
     $display = array(
@@ -491,7 +491,7 @@ function field_view_field($obj_type, $object, $field, $instance, $teaser = FALSE
     }
 
     $view = field_default_view($obj_type, $object, $field, $instance, $items, $teaser);
-    // TODO : what about hook_field_attach_view ?
+    // TODO : what about hook_FieldAttach::view ?
 
     // field_default_view() adds a wrapper to handle variables and 'excluded'
     // fields for node templates. We bypass it and render the actual field.
@@ -545,7 +545,7 @@ function field_access($op, $field, $account = NULL) {
  */
 function template_preprocess_field(&$variables) {
   $element = $variables['element'];
-  list(, , $bundle) = field_attach_extract_ids($element['#object_type'], $element['#object']);
+  list(, , $bundle) = FieldAttach::extract_ids($element['#object_type'], $element['#object']);
   $instance = field_info_instance($element['#field_name'], $bundle);
   $field = field_info_field($element['#field_name']);
 
diff --git modules/field/field.test modules/field/field.test
index cadcacd..baf6421 100644
--- modules/field/field.test
+++ modules/field/field.test
@@ -67,7 +67,7 @@ class FieldAttachTestCase extends DrupalWebTestCase {
 
     // Load the "most current revision"
     $entity = field_test_create_stub_entity($eid, 0, $this->instance['bundle']);
-    field_attach_load($entity_type, array($eid => $entity));
+    FieldAttach::load($entity_type, array($eid => $entity));
     foreach ($values[0] as $delta => $value) {
       if ($delta < $this->field['cardinality']) {
         $this->assertEqual($entity->{$this->field_name}[$delta]['value'], $value, "Value $delta is loaded correctly for current revision");
@@ -80,7 +80,7 @@ class FieldAttachTestCase extends DrupalWebTestCase {
     // Load every revision
     for ($evid = 0; $evid < 4; ++$evid) {
       $entity = field_test_create_stub_entity($eid, $evid, $this->instance['bundle']);
-      field_attach_load_revision($entity_type, array($eid => $entity));
+      FieldAttach::load_revision($entity_type, array($eid => $entity));
       foreach ($values[$evid] as $delta => $value) {
         if ($delta < $this->field['cardinality']) {
           $this->assertEqual($entity->{$this->field_name}[$delta]['value'], $value, "Value $delta for revision $evid is loaded correctly");
@@ -113,7 +113,7 @@ class FieldAttachTestCase extends DrupalWebTestCase {
       $values[$delta]['value'] = mt_rand(1, 127);
     }
     $entity->{$this->field_name} = $rev_values[0] = $values;
-    field_attach_insert($entity_type, $entity);
+    FieldAttach::insert($entity_type, $entity);
 
     $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC);
     foreach ($values as $delta => $value) {
@@ -133,7 +133,7 @@ class FieldAttachTestCase extends DrupalWebTestCase {
       $values[$delta]['value'] = mt_rand(1, 127);
     }
     $entity->{$this->field_name} = $rev_values[1] = $values;
-    field_attach_update($entity_type, $entity);
+    FieldAttach::update($entity_type, $entity);
     $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC);
     foreach ($values as $delta => $value) {
       if ($delta < $this->field['cardinality']) {
@@ -163,7 +163,7 @@ class FieldAttachTestCase extends DrupalWebTestCase {
     // Check that update leaves the field data untouched if $object has no
     // $field_name key.
     unset($entity->{$this->field_name});
-    field_attach_update($entity_type, $entity);
+    FieldAttach::update($entity_type, $entity);
     $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC);
     foreach ($values as $delta => $value) {
       if ($delta < $this->field['cardinality']) {
@@ -173,7 +173,7 @@ class FieldAttachTestCase extends DrupalWebTestCase {
 
     // Check that update with an empty $object->$field_name empties the field.
     $entity->{$this->field_name} = NULL;
-    field_attach_update($entity_type, $entity);
+    FieldAttach::update($entity_type, $entity);
     $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC);
     $this->assertEqual(count($rows), 0, t("Update with an empty field_name entry empties the field."));
   }
@@ -185,31 +185,31 @@ class FieldAttachTestCase extends DrupalWebTestCase {
     $entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']);
 
     // Insert: Field is missing
-    field_attach_insert($entity_type, $entity);
+    FieldAttach::insert($entity_type, $entity);
     $count = db_result(db_query("SELECT COUNT(*) FROM {{$this->table}}"));
     $this->assertEqual($count, 0, 'Missing field results in no inserts');
 
     // Insert: Field is NULL
     $entity->{$this->field_name} = NULL;
-    field_attach_insert($entity_type, $entity);
+    FieldAttach::insert($entity_type, $entity);
     $count = db_result(db_query("SELECT COUNT(*) FROM {{$this->table}}"));
     $this->assertEqual($count, 0, 'NULL field results in no inserts');
 
     // Add some real data
     $entity->{$this->field_name} = array(0 => array('value' => 1));
-    field_attach_insert($entity_type, $entity);
+    FieldAttach::insert($entity_type, $entity);
     $count = db_result(db_query("SELECT COUNT(*) FROM {{$this->table}}"));
     $this->assertEqual($count, 1, 'Field data saved');
 
     // Update: Field is missing. Data should survive.
     unset($entity->{$this->field_name});
-    field_attach_update($entity_type, $entity);
+    FieldAttach::update($entity_type, $entity);
     $count = db_result(db_query("SELECT COUNT(*) FROM {{$this->table}}"));
     $this->assertEqual($count, 1, 'Missing field leaves data in table');
 
     // Update: Field is NULL. Data should be wiped.
     $entity->{$this->field_name} = NULL;
-    field_attach_update($entity_type, $entity);
+    FieldAttach::update($entity_type, $entity);
     $count = db_result(db_query("SELECT COUNT(*) FROM {{$this->table}}"));
     $this->assertEqual($count, 0, 'NULL field leaves no data in table');
   }
@@ -237,9 +237,9 @@ class FieldAttachTestCase extends DrupalWebTestCase {
       ),
     );
     field_update_instance($this->instance);
-    $entity->content = field_attach_view($entity_type, $entity);
+    $entity->content = FieldAttach::view($entity_type, $entity);
     $output = drupal_render($entity->content);
-    $variables = field_attach_preprocess($entity_type, $entity);
+    $variables = FieldAttach::preprocess($entity_type, $entity);
     $variable = $this->instance['field_name'] . '_rendered';
     $this->assertTrue(isset($variables[$variable]), "Variable $variable is available in templates.");
     $this->content = $output;
@@ -256,9 +256,9 @@ class FieldAttachTestCase extends DrupalWebTestCase {
     // Label hidden.
     $this->instance['display']['full']['label'] = 'hidden';
     field_update_instance($this->instance);
-    $entity->content = field_attach_view($entity_type, $entity);
+    $entity->content = FieldAttach::view($entity_type, $entity);
     $output = drupal_render($entity->content);
-    $variables = field_attach_preprocess($entity_type, $entity);
+    $variables = FieldAttach::preprocess($entity_type, $entity);
     $this->content = $output;
     $this->assertNoRaw($this->instance['label'], "Hidden label: label is not displayed.");
     $this->content = $variables[$variable];
@@ -273,9 +273,9 @@ class FieldAttachTestCase extends DrupalWebTestCase {
       ),
     );
     field_update_instance($this->instance);
-    $entity->content = field_attach_view($entity_type, $entity);
+    $entity->content = FieldAttach::view($entity_type, $entity);
     $output = drupal_render($entity->content);
-    $variables = field_attach_preprocess($entity_type, $entity);
+    $variables = FieldAttach::preprocess($entity_type, $entity);
     $this->assertTrue(isset($variables[$variable]), "Hidden field: variable $variable is available in templates.");
     $this->content = $output;
     $this->assertNoRaw($this->instance['label'], "Hidden field: label is not displayed.");
@@ -295,9 +295,9 @@ class FieldAttachTestCase extends DrupalWebTestCase {
       ),
     );
     field_update_instance($this->instance);
-    $entity->content = field_attach_view($entity_type, $entity);
+    $entity->content = FieldAttach::view($entity_type, $entity);
     $output = drupal_render($entity->content);
-    $variables = field_attach_preprocess($entity_type, $entity);
+    $variables = FieldAttach::preprocess($entity_type, $entity);
     $display = $formatter_setting;
     foreach ($values as $delta => $value) {
       $display .= "|$delta:{$value['value']}";
@@ -322,47 +322,47 @@ class FieldAttachTestCase extends DrupalWebTestCase {
       $values[$delta]['value'] = mt_rand(1, 127);
     }
     $rev[0]->{$this->field_name} = $values;
-    field_attach_insert($entity_type, $rev[0]);
+    FieldAttach::insert($entity_type, $rev[0]);
 
     // Create revision 1
     $rev[1] = field_test_create_stub_entity(0, 1, $this->instance['bundle']);
     $rev[1]->{$this->field_name} = $values;
-    field_attach_update($entity_type, $rev[1]);
+    FieldAttach::update($entity_type, $rev[1]);
 
     // Create revision 2
     $rev[2] = field_test_create_stub_entity(0, 2, $this->instance['bundle']);
     $rev[2]->{$this->field_name} = $values;
-    field_attach_update($entity_type, $rev[2]);
+    FieldAttach::update($entity_type, $rev[2]);
 
     // Confirm each revision loads
     foreach (array_keys($rev) as $vid) {
       $read = field_test_create_stub_entity(0, $vid, $this->instance['bundle']);
-      field_attach_load_revision($entity_type, array(0 => $read));
+      FieldAttach::load_revision($entity_type, array(0 => $read));
       $this->assertEqual(count($read->{$this->field_name}), $this->field['cardinality'], "The test object revision $vid has {$this->field['cardinality']} values.");
     }
 
     // Delete revision 1, confirm the other two still load.
-    field_attach_delete_revision($entity_type, $rev[1]);
+    FieldAttach::delete_revision($entity_type, $rev[1]);
     foreach (array(0, 2) as $vid) {
       $read = field_test_create_stub_entity(0, $vid, $this->instance['bundle']);
-      field_attach_load_revision($entity_type, array(0 => $read));
+      FieldAttach::load_revision($entity_type, array(0 => $read));
       $this->assertEqual(count($read->{$this->field_name}), $this->field['cardinality'], "The test object revision $vid has {$this->field['cardinality']} values.");
     }
 
     // Confirm the current revision still loads
     $read = field_test_create_stub_entity(0, 2, $this->instance['bundle']);
-    field_attach_load($entity_type, array(0 => $read));
+    FieldAttach::load($entity_type, array(0 => $read));
     $this->assertEqual(count($read->{$this->field_name}), $this->field['cardinality'], "The test object current revision has {$this->field['cardinality']} values.");
 
     // Delete all field data, confirm nothing loads
-    field_attach_delete($entity_type, $rev[2]);
+    FieldAttach::delete($entity_type, $rev[2]);
     foreach (array(0, 1, 2) as $vid) {
       $read = field_test_create_stub_entity(0, $vid, $this->instance['bundle']);
-      field_attach_load_revision($entity_type, array(0 => $read));
+      FieldAttach::load_revision($entity_type, array(0 => $read));
       $this->assertIdentical($read->{$this->field_name}, array(), "The test object revision $vid is deleted.");
     }
     $read = field_test_create_stub_entity(0, 2, $this->instance['bundle']);
-    field_attach_load($entity_type, array(0 => $read));
+    FieldAttach::load($entity_type, array(0 => $read));
       $this->assertIdentical($read->{$this->field_name}, array(), "The test object current revision is deleted.");
   }
 
@@ -384,11 +384,11 @@ class FieldAttachTestCase extends DrupalWebTestCase {
     }
     $entity->{$this->field_name} = $values;
     $entity_type = 'test_entity';
-    field_attach_insert($entity_type, $entity);
+    FieldAttach::insert($entity_type, $entity);
 
     // Verify the field data is present on load.
     $entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']);
-    field_attach_load($entity_type, array(0 => $entity));
+    FieldAttach::load($entity_type, array(0 => $entity));
     $this->assertEqual(count($entity->{$this->field_name}), $this->field['cardinality'], "Data are retrieved for the new bundle");
 
     // Rename the bundle. This has to be initiated by the module so that its
@@ -402,7 +402,7 @@ class FieldAttachTestCase extends DrupalWebTestCase {
 
     // Verify the field data is present on load.
     $entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']);
-    field_attach_load($entity_type, array(0 => $entity));
+    FieldAttach::load($entity_type, array(0 => $entity));
     $this->assertEqual(count($entity->{$this->field_name}), $this->field['cardinality'], "Bundle name has been updated in the field storage");
   }
 
@@ -444,11 +444,11 @@ class FieldAttachTestCase extends DrupalWebTestCase {
     $entity->{$this->field_name} = $values;
     $entity->{$field_name} = array(0 => array('value' => 99));
     $entity_type = 'test_entity';
-    field_attach_insert($entity_type, $entity);
+    FieldAttach::insert($entity_type, $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));
+    FieldAttach::load($entity_type, array(0 => $entity));
     $this->assertEqual(count($entity->{$this->field_name}), 4, "First field got loaded");
     $this->assertEqual(count($entity->{$field_name}), 1, "Second field got loaded");
 
@@ -458,7 +458,7 @@ class FieldAttachTestCase extends DrupalWebTestCase {
 
     // Verify no data gets loaded
     $entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']);
-    field_attach_load($entity_type, array(0 => $entity));
+    FieldAttach::load($entity_type, array(0 => $entity));
     $this->assertFalse(isset($entity->{$this->field_name}), "No data for first field");
     $this->assertFalse(isset($entity->{$field_name}), "No data for second field");
 
@@ -486,11 +486,11 @@ class FieldAttachTestCase extends DrupalWebTestCase {
     $this->assertFalse(cache_get($cid, 'cache_field'), 'Non-cached: no initial cache entry');
 
     // Save, and confirm no cache entry
-    field_attach_insert($noncached_type, $entity);
+    FieldAttach::insert($noncached_type, $entity);
     $this->assertFalse(cache_get($cid, 'cache_field'), 'Non-cached: no cache entry on save');
 
     // Load, and confirm no cache entry
-    field_attach_load($noncached_type, array(0 => $entity));
+    FieldAttach::load($noncached_type, array(0 => $entity));
     $this->assertFalse(cache_get($cid, 'cache_field'), 'Non-cached: no cache entry on load');
 
     // Cached type:
@@ -500,20 +500,20 @@ class FieldAttachTestCase extends DrupalWebTestCase {
     $this->assertFalse(cache_get($cid, 'cache_field'), 'Cached: no initial cache entry');
 
     // Save, and confirm no cache entry
-    field_attach_insert($cached_type, $entity);
+    FieldAttach::insert($cached_type, $entity);
     $this->assertFalse(cache_get($cid, 'cache_field'), 'Cached: no cache entry on save');
 
     // Load, and confirm cache entry
-    field_attach_load($cached_type, array(0 => $entity));
+    FieldAttach::load($cached_type, array(0 => $entity));
     $cache = cache_get($cid, 'cache_field');
     $this->assertEqual($cache->data[$this->field_name], $values, 'Cached: correct cache entry on load');
 
     // Delete, and confirm no cache entry
-    field_attach_delete($cached_type, $entity);
+    FieldAttach::delete($cached_type, $entity);
     $this->assertFalse(cache_get($cid, 'cache_field'), 'Cached: no cache entry on save');
   }
 
-  // Verify that field_attach_validate() invokes the correct
+  // Verify that FieldAttach::validate() invokes the correct
   // hook_field_validate.
   function testFieldAttachValidate() {
     $entity_type = 'test_entity';
@@ -530,7 +530,7 @@ class FieldAttachTestCase extends DrupalWebTestCase {
     $entity->{$this->field_name} = $values;
 
     try {
-      field_attach_validate($entity_type, $entity);
+      FieldAttach::validate($entity_type, $entity);
     }
     catch (FieldValidationException $e) {
       $errors = $e->errors;
@@ -556,7 +556,7 @@ class FieldAttachTestCase extends DrupalWebTestCase {
     $entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']);
 
     $form = $form_state = array();
-    field_attach_form($entity_type, $entity, $form, $form_state);
+    FieldAttach::form($entity_type, $entity, $form, $form_state);
 
     $this->assertEqual($form[$this->field_name]['#title'], $this->instance['label'], "Form title is {$this->instance['label']}");
     for ($delta = 0; $delta < $this->field['cardinality']; $delta++) {
@@ -571,7 +571,7 @@ class FieldAttachTestCase extends DrupalWebTestCase {
 
     // Build the form.
     $form = $form_state = array();
-    field_attach_form($entity_type, $entity, $form, $form_state);
+    FieldAttach::form($entity_type, $entity, $form, $form_state);
 
     // Simulate incoming values.
     $values = array();
@@ -589,7 +589,7 @@ class FieldAttachTestCase extends DrupalWebTestCase {
     $values[1]['value'] = 0;
 
     $form_state['values'] = array($this->field_name => $values);
-    field_attach_submit($entity_type, $entity, $form, $form_state);
+    FieldAttach::submit($entity_type, $entity, $form, $form_state);
 
     asort($weights);
     $expected_values = array();
diff --git modules/field/modules/field_sql_storage/field_sql_storage.module modules/field/modules/field_sql_storage/field_sql_storage.module
index d32a894..04cba88 100644
--- modules/field/modules/field_sql_storage/field_sql_storage.module
+++ modules/field/modules/field_sql_storage/field_sql_storage.module
@@ -184,7 +184,7 @@ function field_sql_storage_field_storage_load($obj_type, $objects, $age, $skip_f
   $field_ids = array();
   $delta_count = array();
   foreach ($objects as $obj) {
-    list($id, $vid, $bundle) = field_attach_extract_ids($obj_type, $obj);
+    list($id, $vid, $bundle) = FieldAttach::extract_ids($obj_type, $obj);
     foreach (field_info_instances($bundle) as $instance) {
       $field_ids[$instance['field_name']][] = $load_current ? $id : $vid;
       $delta_count[$id][$instance['field_name']] = 0;
@@ -230,7 +230,7 @@ function field_sql_storage_field_storage_load($obj_type, $objects, $age, $skip_f
  * Implementation of hook_field_storage_write().
  */
 function field_sql_storage_field_storage_write($obj_type, $object, $op, $skip_fields) {
-  list($id, $vid, $bundle) = field_attach_extract_ids($obj_type, $object);
+  list($id, $vid, $bundle) = FieldAttach::extract_ids($obj_type, $object);
   $etid = _field_sql_storage_etid($obj_type);
 
   $instances = field_info_instances($bundle);
@@ -307,7 +307,7 @@ function field_sql_storage_field_storage_write($obj_type, $object, $op, $skip_fi
  * This function actually deletes the data from the database.
  */
 function field_sql_storage_field_storage_delete($obj_type, $object) {
-  list($id, $vid, $bundle) = field_attach_extract_ids($obj_type, $object);
+  list($id, $vid, $bundle) = FieldAttach::extract_ids($obj_type, $object);
   $etid = _field_sql_storage_etid($obj_type);
 
   $instances = field_info_instances($bundle);
@@ -332,7 +332,7 @@ function field_sql_storage_field_storage_delete($obj_type, $object) {
  * This function actually deletes the data from the database.
  */
 function field_sql_storage_field_storage_delete_revision($obj_type, $object) {
-  list($id, $vid, $bundle) = field_attach_extract_ids($obj_type, $object);
+  list($id, $vid, $bundle) = FieldAttach::extract_ids($obj_type, $object);
   $etid = _field_sql_storage_etid($obj_type);
 
   if (isset($vid)) {
diff --git modules/field/modules/text/text.test modules/field/modules/text/text.test
index 59cf593..790b8ef 100644
--- modules/field/modules/text/text.test
+++ modules/field/modules/text/text.test
@@ -48,12 +48,12 @@ class TextFieldTestCase extends DrupalWebTestCase {
       ),
     );
     field_create_instance($this->instance);
-    // Test valid and invalid values with field_attach_validate().
+    // Test valid and invalid values with FieldAttach::validate().
     $entity = field_test_create_stub_entity(0, 0, FIELD_TEST_BUNDLE);
     for ($i = 0; $i <= $max_length + 2; $i++) {
       $entity->{$this->field['field_name']}[0]['value'] = str_repeat('x', $i);
       try {
-        field_attach_validate('test_entity', $entity);
+        FieldAttach::validate('test_entity', $entity);
         $this->assertTrue($i <= $max_length, "Length $i does not cause validation error when max_length is $max_length");
       }
       catch (FieldValidationException $e) {
@@ -109,7 +109,7 @@ class TextFieldTestCase extends DrupalWebTestCase {
 
     // Display the object.
     $entity = field_test_entity_load($id);
-    $entity->content = field_attach_view($entity_type, $entity);
+    $entity->content = FieldAttach::view($entity_type, $entity);
     $this->content = drupal_render($entity->content);
     $this->assertText($value, 'Filtered tags are not displayed');
   }
@@ -163,7 +163,7 @@ class TextFieldTestCase extends DrupalWebTestCase {
 
     // Display the object.
     $entity = field_test_entity_load($id);
-    $entity->content = field_attach_view($entity_type, $entity);
+    $entity->content = FieldAttach::view($entity_type, $entity);
     $this->content = drupal_render($entity->content);
     $this->assertNoRaw($value, 'Filtered tags are not displayed');
     $this->assertRaw(str_replace('<br />', '', $value), t('Filtered value is displayed correctly'));
@@ -186,7 +186,7 @@ class TextFieldTestCase extends DrupalWebTestCase {
 
     // Display the object.
     $entity = field_test_entity_load($id);
-    $entity->content = field_attach_view($entity_type, $entity);
+    $entity->content = FieldAttach::view($entity_type, $entity);
     $this->content = drupal_render($entity->content);
     $this->assertRaw($value, t('Value is displayed unfiltered'));
   }
diff --git modules/node/node.module modules/node/node.module
index 7a1ce73..8bdb33f 100644
--- modules/node/node.module
+++ modules/node/node.module
@@ -587,7 +587,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);
+      FieldAttach::rename_bundle($type->old_type, $type->type);
     }
     module_invoke_all('node_type', 'update', $type);
     return SAVED_UPDATED;
@@ -598,7 +598,7 @@ function node_type_save($info) {
       ->fields($fields)
       ->execute();
 
-    field_attach_create_bundle($type->type);
+    FieldAttach::create_bundle($type->type);
 
     module_invoke_all('node_type', 'insert', $type);
     return SAVED_NEW;
@@ -927,10 +927,10 @@ function node_load_multiple($nids = array(), $conditions = array(), $reset = FAL
 
     // Attach fields.
     if ($vid) {
-      field_attach_load_revision('node', $queried_nodes);
+      FieldAttach::load_revision('node', $queried_nodes);
     }
     else {
-      field_attach_load('node', $queried_nodes);
+      FieldAttach::load('node', $queried_nodes);
     }
 
     // Call hook_node_load(), pass the node types so modules can return early
@@ -1069,7 +1069,7 @@ function node_submit($node) {
  *   omitted (or $node->is_new is TRUE), a new node will be added.
  */
 function node_save(&$node) {
-  field_attach_presave('node', $node);
+  FieldAttach::presave('node', $node);
   // Let modules modify the node before it is saved to the database.
   node_invoke_node($node, 'presave');
   global $user;
@@ -1153,8 +1153,7 @@ function node_save(&$node) {
   node_invoke($node, $op);
 
   // Save fields.
-  $function = "field_attach_$op";
-  $function('node', $node);
+  FieldAttach::$op('node', $node);
 
   node_invoke_node($node, $op);
 
@@ -1304,7 +1303,7 @@ function node_build_content($node, $teaser = FALSE) {
   }
 
   // Build fields content.
-  $node->content += field_attach_view('node', $node, $teaser);
+  $node->content += FieldAttach::view('node', $node, $teaser);
 
   // Allow modules to make their own additions to the node.
   node_invoke_node($node, 'view', $teaser);
diff --git modules/node/node.pages.inc modules/node/node.pages.inc
index 6dfc14e..322e247 100644
--- modules/node/node.pages.inc
+++ modules/node/node.pages.inc
@@ -74,7 +74,7 @@ function node_form_validate($form, &$form_state) {
   // Field validation. Requires access to $form_state, so this cannot be
   // done in node_validate() as it currently exists.
   $node = (object)$node;
-  field_attach_form_validate('node', $node, $form, $form_state);
+  FieldAttach::form_validate('node', $node, $form, $form_state);
 }
 
 function node_object_prepare(&$node) {
@@ -280,7 +280,7 @@ function node_form(&$form_state, $node) {
   $form['#theme'] = array($node->type . '_node_form', 'node_form');
 
   $form['#builder_function'] = 'node_form_submit_build_node';
-  field_attach_form('node', $node, $form, $form_state);
+  FieldAttach::form('node', $node, $form, $form_state);
 
   return $form;
 }
@@ -491,7 +491,7 @@ function node_form_submit_build_node($form, &$form_state) {
   form_execute_handlers('submit', $form, $form_state);
   $node = node_submit($form_state['values']);
 
-  field_attach_submit('node', $node, $form, $form_state);
+  FieldAttach::submit('node', $node, $form, $form_state);
 
   $form_state['node'] = (array)$node;
   $form_state['rebuild'] = TRUE;
diff --git modules/simpletest/tests/field_test.module modules/simpletest/tests/field_test.module
index 5c07b53..ed2332c 100644
--- modules/simpletest/tests/field_test.module
+++ modules/simpletest/tests/field_test.module
@@ -88,7 +88,7 @@ function field_test_create_bundle($bundle, $text) {
   $bundles += array($bundle => $text);
   variable_set('field_test_bundles', $bundles);
 
-  field_attach_create_bundle($bundle);
+  FieldAttach::create_bundle($bundle);
 }
 
 function field_test_rename_bundle($bundle_old, $bundle_new) {
@@ -97,7 +97,7 @@ function field_test_rename_bundle($bundle_old, $bundle_new) {
   unset($bundles[$bundle_old]);
   variable_set('field_test_bundles', $bundles);
 
-  field_attach_rename_bundle($bundle_old, $bundle_new);
+  FieldAttach::rename_bundle($bundle_old, $bundle_new);
 }
 
 function field_test_delete_bundle($bundle) {
@@ -105,7 +105,7 @@ function field_test_delete_bundle($bundle) {
   unset($bundles[$bundle]);
   variable_set('field_test_bundles', $bundles);
 
-  field_attach_delete_bundle($bundle);
+  FieldAttach::delete_bundle($bundle);
 }
 
 /**
@@ -148,17 +148,17 @@ function field_test_entity_load($ftid, $ftvid = NULL) {
 
   // Attach fields.
   if ($ftvid) {
-    field_attach_load_revision('test_entity', $entities);
+    FieldAttach::load_revision('test_entity', $entities);
   }
   else {
-    field_attach_load('test_entity', $entities);
+    FieldAttach::load('test_entity', $entities);
   }
 
   return $entities[$ftid];
 }
 
 function field_test_entity_save(&$entity) {
-  field_attach_presave('test_entity', $entity);
+  FieldAttach::presave('test_entity', $entity);
 
   $entity->is_new = FALSE;
   if (empty($entity->ftid)) {
@@ -194,8 +194,7 @@ function field_test_entity_save(&$entity) {
   }
 
   // Save fields.
-  $function = "field_attach_$op";
-  $function('test_entity', $entity);
+  FieldAttach::$op('test_entity', $entity);
 }
 
 function field_test_entity_add($fttype) {
@@ -230,7 +229,7 @@ function field_test_entity_form(&$form_state, $entity) {
 
   // Add field widgets.
   $form['#builder_function'] = 'field_test_entity_form_submit_builder';
-  field_attach_form('test_entity', $entity, $form, $form_state);
+  FieldAttach::form('test_entity', $entity, $form, $form_state);
 
   $form['revision'] = array(
     '#access' => user_access('administer field_test content'),
@@ -253,7 +252,7 @@ function field_test_entity_form(&$form_state, $entity) {
  */
 function field_test_entity_form_validate($form, &$form_state) {
   $entity = field_test_create_stub_entity($form_state['values']['ftid'], $form_state['values']['ftvid'], $form_state['values']['fttype']);
-  field_attach_form_validate('test_entity', $entity, $form, $form_state);
+  FieldAttach::form_validate('test_entity', $entity, $form, $form_state);
 }
 
 /**
@@ -283,7 +282,7 @@ function field_test_entity_form_submit($form, &$form_state) {
  */
 function field_test_entity_form_submit_builder($form, &$form_state) {
   $entity = field_test_create_stub_entity($form_state['values']['ftid'], $form_state['values']['ftvid'], $form_state['values']['fttype']);
-  field_attach_submit('test_entity', $entity, $form, $form_state);
+  FieldAttach::submit('test_entity', $entity, $form, $form_state);
 
   $form_state['test_entity'] = (array)$entity;
   $form_state['rebuild'] = TRUE;
diff --git modules/user/user.module modules/user/user.module
index 15f537d..34ddfac 100644
--- modules/user/user.module
+++ modules/user/user.module
@@ -267,7 +267,7 @@ function user_load_multiple($uids = array(), $conditions = array(), $reset = FAL
         }
       }
 
-      field_attach_load('user', $queried_users);
+      FieldAttach::load('user', $queried_users);
 
       // Invoke hook_user_load() on the users loaded from the database
       // and add them to the static cache.
@@ -276,8 +276,6 @@ function user_load_multiple($uids = array(), $conditions = array(), $reset = FAL
         $function($queried_users);
       }
 
-
-
       $users = $users + $queried_users;
       $user_cache = $user_cache + $queried_users;
     }
@@ -391,10 +389,10 @@ function user_save($account, $edit = array(), $category = 'account') {
   $field_form = array();
   $field_form_state = array();
   $edit = (object) $edit;
-  field_attach_form('user', $edit, $field_form, $field_form_state);
+  FieldAttach::form('user', $edit, $field_form, $field_form_state);
 
   // Presave fields.
-  field_attach_presave('user', $edit);
+  FieldAttach::presave('user', $edit);
 
   $edit = (array) $edit;
 
@@ -494,7 +492,7 @@ function user_save($account, $edit = array(), $category = 'account') {
 
     // Save Field data.
     $object = (object) $edit;
-    field_attach_update('user', $object);
+    FieldAttach::update('user', $object);
 
     // Refresh user object.
     $user = user_load($account->uid, TRUE);
@@ -530,7 +528,7 @@ function user_save($account, $edit = array(), $category = 'account') {
     $user = user_load($edit['uid'], TRUE);
 
     $object = (object) $edit;
-    field_attach_insert('user', $object);
+    FieldAttach::insert('user', $object);
 
     user_module_invoke('insert', $edit, $user, $category);
 
@@ -2024,7 +2022,7 @@ function user_build_content(&$account) {
   // Build fields content.
   // TODO D7 : figure out where exactly this needs to go
   // TODO D7 : $page / $teaser ??
-  $account->content += field_attach_view('user', $account);
+  $account->content += FieldAttach::view('user', $account);
 
   user_module_invoke('view', $edit, $account);
 
diff --git modules/user/user.pages.inc modules/user/user.pages.inc
index 1a89efc..bbce7e4 100644
--- modules/user/user.pages.inc
+++ modules/user/user.pages.inc
@@ -201,7 +201,7 @@ function template_preprocess_user_profile(&$variables) {
   $variables['user_profile'] = implode($variables['profile']);
 
   // Add $FIELD_NAME_rendered variables for fields.
-  $variables += field_attach_preprocess('user', $variables['account']);
+  $variables += FieldAttach::preprocess('user', $variables['account']);
 }
 
 /**
@@ -266,7 +266,7 @@ function user_profile_form($form_state, $account, $category = 'account') {
   $form = _user_forms($edit, $account, $category);
 
   // Attach field widgets.
-  field_attach_form('user', (object) $edit, $form, $form_state);
+  FieldAttach::form('user', (object) $edit, $form, $form_state);
 
   $form['_category'] = array('#type' => 'value', '#value' => $category);
   $form['_account'] = array('#type' => 'value', '#value' => $account);
@@ -289,7 +289,7 @@ function user_profile_form($form_state, $account, $category = 'account') {
  */
 function user_profile_form_validate($form, &$form_state) {
   $edit = (object)$form_state['values'];
-  field_attach_form_validate('user', $edit, $form, $form_state);
+  FieldAttach::form_validate('user', $edit, $form, $form_state);
   $edit = (array)$edit;
   user_module_invoke('validate', $edit, $form_state['values']['_account'], $form_state['values']['_category']);
   // Validate input to ensure that non-privileged users can't alter protected data.
@@ -309,7 +309,7 @@ function user_profile_form_submit($form, &$form_state) {
   unset($form_state['values']['_account'], $form_state['values']['op'], $form_state['values']['submit'], $form_state['values']['cancel'], $form_state['values']['form_token'], $form_state['values']['form_id'], $form_state['values']['_category'], $form_state['values']['form_build_id']);
 
   $edit = (object)$form_state['values'];
-  field_attach_submit('user', $edit, $form, $form_state);
+  FieldAttach::submit('user', $edit, $form, $form_state);
   $edit = (array)$edit;
   user_module_invoke('submit', $edit, $account, $category);
   user_save($account, $edit, $category);
