From 17f76e227d8045577caaf8c7a8d845d4efb164ab Mon Sep 17 00:00:00 2001
From: webchick <webchick@24967.no-reply.drupal.org>
Date: Wed, 27 Feb 2013 22:13:22 -0500
Subject: [PATCH] Issue #1922892 by yched: Last missing bit from D7
 '_field_info_collate_fields()' patch.

---
 core/modules/field/field.api.php                        | 9 ++++-----
 core/modules/field_sql_storage/field_sql_storage.module | 4 ++++
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php
index 29112eff4d1d..16b0143e16ed 100644
--- a/core/modules/field/field.api.php
+++ b/core/modules/field/field.api.php
@@ -1349,11 +1349,6 @@ function hook_field_storage_details_alter(&$details, $field) {
  * Modules implementing this hook should load field values and add them to
  * objects in $entities. Fields with no values should be added as empty arrays.
  *
- * By the time this hook runs, the relevant field definitions have been
- * populated and cached in FieldInfo, so calling field_info_field_by_id() on
- * each field individually is more efficient than loading all fields in memory
- * upfront with field_info_field_by_ids() (which is uncached).
- *
  * @param $entity_type
  *   The type of entity, such as 'node' or 'user'.
  * @param $entities
@@ -1374,6 +1369,10 @@ function hook_field_storage_load($entity_type, $entities, $age, $fields, $option
   $load_current = $age == FIELD_LOAD_CURRENT;
 
   foreach ($fields as $field_id => $ids) {
+    // By the time this hook runs, the relevant field definitions have been
+    // populated and cached in FieldInfo, so calling field_info_field_by_id()
+    // on each field individually is more efficient than loading all fields in
+    // memory upfront with field_info_field_by_ids().
     $field = field_info_field_by_id($field_id);
     $field_name = $field['field_name'];
     $table = $load_current ? _field_sql_storage_tablename($field) : _field_sql_storage_revision_tablename($field);
diff --git a/core/modules/field_sql_storage/field_sql_storage.module b/core/modules/field_sql_storage/field_sql_storage.module
index accca35eed9b..e604ac692443 100644
--- a/core/modules/field_sql_storage/field_sql_storage.module
+++ b/core/modules/field_sql_storage/field_sql_storage.module
@@ -356,6 +356,10 @@ function field_sql_storage_field_storage_load($entity_type, $entities, $age, $fi
   $load_current = $age == FIELD_LOAD_CURRENT;
 
   foreach ($fields as $field_id => $ids) {
+    // By the time this hook runs, the relevant field definitions have been
+    // populated and cached in FieldInfo, so calling field_info_field_by_id()
+    // on each field individually is more efficient than loading all fields in
+    // memory upfront with field_info_field_by_ids().
     $field = field_info_field_by_id($field_id);
     $field_name = $field['field_name'];
     $table = $load_current ? _field_sql_storage_tablename($field) : _field_sql_storage_revision_tablename($field);
-- 
GitLab