From 6a686533ab84769fa8fdcf1df67663cc4b3f11c3 Mon Sep 17 00:00:00 2001
From: Angie Byron <webchick@24967.no-reply.drupal.org>
Date: Sat, 11 Jul 2009 00:56:45 +0000
Subject: [PATCH] #516124 by yched: Clean up some Field API TODOs and remove
 unused APIs.

---
 modules/field/field.api.php     |  6 +-----
 modules/field/field.attach.inc  | 10 ----------
 modules/field/field.crud.inc    |  5 +----
 modules/field/field.default.inc |  6 ------
 modules/field/field.form.inc    |  2 --
 modules/field/field.module      |  8 +-------
 6 files changed, 3 insertions(+), 34 deletions(-)

diff --git a/modules/field/field.api.php b/modules/field/field.api.php
index 76268b908177..21d328be80b9 100644
--- a/modules/field/field.api.php
+++ b/modules/field/field.api.php
@@ -368,9 +368,6 @@ function hook_field_validate($obj_type, $object, $field, $instance, $items, &$er
 /**
  * Define custom presave behavior for this module's field types.
  *
- * TODO: The behavior of this hook is going to change (see
- * field_attach_presave()).
- *
  * @param $obj_type
  *   The type of $object.
  * @param $object
@@ -507,8 +504,7 @@ function hook_field_prepare_translation($obj_type, $object, $field, $instance, $
  * Field API will call this function as many times as needed.
  *
  * @param $form
- *   The entire form array, $form['#node'] holds node information.
- *   TODO: Not #node any more.
+ *   The entire form array.
  * @param $form_state
  *   The form_state, $form_state['values'][$field['field_name']]
  *   holds the field's form values.
diff --git a/modules/field/field.attach.inc b/modules/field/field.attach.inc
index 08ef44173825..564f86524523 100644
--- a/modules/field/field.attach.inc
+++ b/modules/field/field.attach.inc
@@ -6,12 +6,6 @@
  * 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 - 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 thrown by field_attach_validate() on field validation errors.
  */
@@ -364,7 +358,6 @@ function _field_invoke_multiple_default($op, $obj_type, $objects, &$a = NULL, &$
  * field_attach_view().
  */
 function field_attach_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);
 
   // Let other modules make changes to the form.
@@ -512,7 +505,6 @@ function field_attach_load_revision($obj_type, $objects) {
  */
 function field_attach_validate($obj_type, $object) {
   $errors = array();
-  _field_invoke_default('validate', $obj_type, $object, $errors);
   _field_invoke('validate', $obj_type, $object, $errors);
 
   // Let other modules validate the object.
@@ -611,8 +603,6 @@ function field_attach_submit($obj_type, $object, $form, &$form_state) {
  *   The object with fields to process.
  */
 function field_attach_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);
 
   // Let other modules act on presaving the object.
diff --git a/modules/field/field.crud.inc b/modules/field/field.crud.inc
index 77cc9fdc277f..dbcbda92e6c3 100644
--- a/modules/field/field.crud.inc
+++ b/modules/field/field.crud.inc
@@ -102,9 +102,6 @@
  *     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()).
- *     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
@@ -276,7 +273,7 @@ function field_create_field($field) {
 
   // Invoke external hooks after the cache is cleared for API consistency.
   module_invoke_all('field_create_field', $field);
-  
+
   return $field;
 }
 
diff --git a/modules/field/field.default.inc b/modules/field/field.default.inc
index daac08fa090c..461986358171 100644
--- a/modules/field/field.default.inc
+++ b/modules/field/field.default.inc
@@ -21,15 +21,9 @@ function field_default_extract_form_values($obj_type, $object, $field, $instance
   }
 }
 
-function field_default_validate($obj_type, $object, $field, $instance, $items) {
-  // TODO: here we could validate that required fields are filled in (for programmatic save)
-}
-
 function field_default_submit($obj_type, $object, $field, $instance, &$items, $form, &$form_state) {
   $field_name = $field['field_name'];
 
-  // TODO: should me move what's below to __extract_form_values ?
-
   // Reorder items to account for drag-n-drop reordering.
   if (field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_DEFAULT) {
     $items = _field_sort_items($field, $items);
diff --git a/modules/field/field.form.inc b/modules/field/field.form.inc
index 4b15d2c427b2..c3bb8bd79a9c 100644
--- a/modules/field/field.form.inc
+++ b/modules/field/field.form.inc
@@ -6,8 +6,6 @@
  * Field forms management.
  */
 
-// TODO : merge with field.default.inc ?
-
 /**
  * Create a separate form element for each field.
  */
diff --git a/modules/field/field.module b/modules/field/field.module
index 70ae73dde8f8..0bfd915533f4 100644
--- a/modules/field/field.module
+++ b/modules/field/field.module
@@ -323,18 +323,12 @@ function _field_sort_items_value_helper($a, $b) {
 
 /**
  * Registry of available build modes.
- * TODO : move into hook_fieldable_info() ?
  */
 function field_build_modes($obj_type) {
   static $info;
 
   if (!isset($info[$obj_type])) {
-    // module_invoke_all messes numeric keys.
-    // TODO : revisit when we move away from numeric build modes.
-    $info[$obj_type] = array();
-    foreach (module_implements('field_build_modes') as $module) {
-      $info[$obj_type] += module_invoke($module, 'field_build_modes', $obj_type);
-    }
+    $info[$obj_type] = module_invoke_all('field_build_modes', $obj_type);
   }
   return $info[$obj_type];
 }
-- 
GitLab