commit e02a1bb331f075504a6b562b8f51e451f6f4f85d Author: Jeff Geerling Date: Tue Sep 11 15:32:54 2012 -0500 1040790-89 diff --git a/core/modules/field/field.info.inc b/core/modules/field/field.info.inc index ffd58a2..aa70899 100644 --- a/core/modules/field/field.info.inc +++ b/core/modules/field/field.info.inc @@ -339,9 +339,11 @@ function field_info_bundles($entity_type = NULL) { * Returns all field definitions. * * This function does not read from cached data, and the returned array - * can be costly memory-wise. When iterating over the fields present in a given - * bundle after a call to field_info_instances($entity_type, $bundle), it is - * recommended to use field_info_field() on each individual field instead. + * can be very large, depending on the number of bundles, fields, and instances. + * + * When iterating over the fields present in a given bundle after a call to + * field_info_instances($entity_type, $bundle), it is recommended to use + * field_info_field() on each individual field instead. * * @return * An array of field definitions, keyed by field name. Each field has an @@ -398,9 +400,11 @@ function field_info_field_by_id($field_id) { * Returns the same data as field_info_field_by_id() for every field. * * This function does not read from cached data, and the returned array - * can be costly memory-wise. When iterating over the fields present in a given - * bundle after a call to field_info_instances($entity_type, $bundle), it is - * recommended to use field_info_field_by_id() on each individual field instead. + * can be very large, depending on the number of bundles, fields, and instances. + * + * When iterating over the fields present in a given bundle after a call to + * field_info_instances($entity_type, $bundle), it is recommended to use + * field_info_field() on each individual field instead. * * @return * An array, each key is a field ID and the values are field arrays as @@ -420,7 +424,7 @@ function field_info_field_by_ids() { * * When retrieving the instances of a specific bundle (i.e. when both * $entity_type and $bundle_name are provided, the function also populates a - * static chache with the corresponding field definitions, allowing a fast + * static cache with the corresponding field definitions, allowing fast * retrieval of field_info_field() later in the request. * * @param $entity_type @@ -453,7 +457,7 @@ function field_info_instances($entity_type = NULL, $bundle_name = NULL) { * Returns an array of instance data for a specific field and bundle. * * The function populates a static cache with all fields and instances used in - * the bundle, allowing a fast retrieval of field_info_field() or + * the bundle, allowing fast retrieval of field_info_field() or * field_info_instance() later in the request. * * @param $entity_type diff --git a/core/modules/field/lib/Drupal/field/FieldInfo.php b/core/modules/field/lib/Drupal/field/FieldInfo.php index 73dcbf9..a2fb97b 100644 --- a/core/modules/field/lib/Drupal/field/FieldInfo.php +++ b/core/modules/field/lib/Drupal/field/FieldInfo.php @@ -10,6 +10,10 @@ namespace Drupal\field; /** * Provides field and instance definitions for the current runtime environment. * + * Use getFields(), getFieldsById() and getInstances() sparingly. These methods + * read all fields or instances on all bundles and do not read from or populate + * caches. + * * A Drupal\field\FieldInfo object is created and statically persisted through * the request by the field_info_cache() function. The object properties act as * a "static cache" of fields and instances definitions. The information is @@ -20,14 +24,9 @@ namespace Drupal\field; * * Cache entries are loaded for bundles as a whole, optimizing memory and CPU * usage for the most common pattern of iterating over all instances of a bundle - * (and then probably accessing each corresponding field) rather than accessing - * a single instance. The specific caching strategy and interdependencies - * between fields and instances make the DrupalCacheArray class unfit here. - * - * The getFields(), getFieldsById() and getInstances(), methods, that retrieve - * all fields or all instances across all bundles, do not read from the caches, - * and do not populate the caches either. As such, they should be used - * sparingly. + * rather than accessing a single instance. The specific caching strategy and + * interdependencies between fields and instances make using DrupalCacheArray + * unfit here. */ class FieldInfo { @@ -266,7 +265,7 @@ class FieldInfo { /** * Retrieves the instances and extra fields for a bundle. * - * The function also populates the corressonding field definitions in the + * The function also populates the corresponding field definitions in the * "static" cache. * * @param $entity_type