Index: includes/entity.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/entity.inc,v
retrieving revision 1.1
diff -u -p -r1.1 entity.inc
--- includes/entity.inc	25 Aug 2009 21:53:47 -0000	1.1
+++ includes/entity.inc	15 Oct 2009 15:57:03 -0000
@@ -223,8 +223,9 @@ class DrupalDefaultEntityController impl
   /**
    * Attach data to entities upon loading.
    *
-   * This will attach fields, if the entity is fieldable. It also calls
-   * hook_TYPE_load() on the loaded entities. For example
+   * This will attach fields, if the entity is fieldable. It calls
+   * hook_entity_load() for modules which need to add data to all entities.
+   * It also calls hook_TYPE_load() on the loaded entities. For example
    * hook_node_load() or hook_user_load(). If your hook_TYPE_load()
    * expects special parameters apart from the queried entities, you can set
    * $this->hookLoadArguments prior to calling the method.
@@ -241,6 +242,11 @@ class DrupalDefaultEntityController impl
       }
     }
 
+    // Call hook_entity_load().
+    foreach (module_implements('entity_load') as $module) {
+      $function = $module . '_entity_load';
+      $function($queried_entities, $this->entityType);
+    }
     // Call hook_TYPE_load(). The first argument for hook_TYPE_load() are
     // always the queried entities, followed by additional arguments set in
     // $this->hookLoadArguments.
Index: modules/field/field.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.test,v
retrieving revision 1.60
diff -u -p -r1.60 field.test
--- modules/field/field.test	15 Oct 2009 12:44:34 -0000	1.60
+++ modules/field/field.test	15 Oct 2009 15:57:04 -0000
@@ -1342,7 +1342,7 @@ class FieldFormTestCase extends FieldTes
     preg_match('|test-entity/(\d+)/edit|', $this->url, $match);
     $id = $match[1];
     $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created');
-    $entity = field_test_entity_load($id);
+    $entity = field_test_entity_test_load($id);
     $this->assertEqual($entity->{$this->field_name}[$langcode][0]['value'], $value, 'Field value was saved');
 
     // Display edit form.
@@ -1355,7 +1355,7 @@ class FieldFormTestCase extends FieldTes
     $edit = array("{$this->field_name}[$langcode][0][value]" => $value);
     $this->drupalPost(NULL, $edit, t('Save'));
     $this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), 'Entity was updated');
-    $entity = field_test_entity_load($id);
+    $entity = field_test_entity_test_load($id);
     $this->assertEqual($entity->{$this->field_name}[$langcode][0]['value'], $value, 'Field value was updated');
 
     // Empty the field.
@@ -1363,7 +1363,7 @@ class FieldFormTestCase extends FieldTes
     $edit = array("{$this->field_name}[$langcode][0][value]" => $value);
     $this->drupalPost('test-entity/' . $id . '/edit', $edit, t('Save'));
     $this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), 'Entity was updated');
-    $entity = field_test_entity_load($id);
+    $entity = field_test_entity_test_load($id);
     $this->assertIdentical($entity->{$this->field_name}, array(), 'Field was emptied');
 
   }
@@ -1389,7 +1389,7 @@ class FieldFormTestCase extends FieldTes
     preg_match('|test-entity/(\d+)/edit|', $this->url, $match);
     $id = $match[1];
     $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created');
-    $entity = field_test_entity_load($id);
+    $entity = field_test_entity_test_load($id);
     $this->assertEqual($entity->{$this->field_name}[$langcode][0]['value'], $value, 'Field value was saved');
 
     // Edit with missing required value.
@@ -1469,7 +1469,7 @@ class FieldFormTestCase extends FieldTes
     preg_match('|test-entity/(\d+)/edit|', $this->url, $match);
     $id = $match[1];
     $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created');
-    $entity = field_test_entity_load($id);
+    $entity = field_test_entity_test_load($id);
     ksort($field_values);
     $field_values = array_values($field_values);
     $this->assertIdentical($entity->{$this->field_name}[$langcode], $field_values, 'Field values were saved in the correct order');
Index: modules/field/modules/text/text.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/text/text.test,v
retrieving revision 1.13
diff -u -p -r1.13 text.test
--- modules/field/modules/text/text.test	15 Oct 2009 12:44:34 -0000	1.13
+++ modules/field/modules/text/text.test	15 Oct 2009 15:57:04 -0000
@@ -115,7 +115,7 @@ class TextFieldTestCase extends DrupalWe
     $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), t('Entity was created'));
 
     // Display the object.
-    $entity = field_test_entity_load($id);
+    $entity = field_test_entity_test_load($id);
     $entity->content = field_attach_view($entity_type, $entity);
     $this->content = drupal_render($entity->content);
     $this->assertText($value, 'Filtered tags are not displayed');
@@ -179,7 +179,7 @@ class TextFieldTestCase extends DrupalWe
     $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), t('Entity was created'));
 
     // Display the object.
-    $entity = field_test_entity_load($id);
+    $entity = field_test_entity_test_load($id);
     $entity->content = field_attach_view($entity_type, $entity);
     $this->content = drupal_render($entity->content);
     $this->assertNoRaw($value, t('HTML tags are not displayed.'));
@@ -212,7 +212,7 @@ class TextFieldTestCase extends DrupalWe
     $this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), t('Entity was updated'));
 
     // Display the object.
-    $entity = field_test_entity_load($id);
+    $entity = field_test_entity_test_load($id);
     $entity->content = field_attach_view($entity_type, $entity);
     $this->content = drupal_render($entity->content);
     $this->assertRaw($value, t('Value is displayed unfiltered'));
Index: modules/simpletest/tests/field_test.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/field_test.module,v
retrieving revision 1.30
diff -u -p -r1.30 field_test.module
--- modules/simpletest/tests/field_test.module	15 Oct 2009 12:44:36 -0000	1.30
+++ modules/simpletest/tests/field_test.module	15 Oct 2009 15:57:04 -0000
@@ -38,7 +38,7 @@ function field_test_menu() {
       'type' => MENU_NORMAL_ITEM,
     );
   }
-  $items['test-entity/%field_test_entity/edit'] = array(
+  $items['test-entity/%field_test_entity_test/edit'] = array(
     'title' => 'Edit test entity',
     'page callback' => 'field_test_entity_edit',
     'page arguments' => array(1),
@@ -188,7 +188,7 @@ function field_test_create_stub_entity($
   return $entity;
 }
 
-function field_test_entity_load($ftid, $ftvid = NULL) {
+function field_test_entity_test_load($ftid, $ftvid = NULL) {
   // Load basic strucure.
   $query = db_select('test_entity', 'fte', array())
     ->fields('fte')
Index: modules/system/system.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.api.php,v
retrieving revision 1.88
diff -u -p -r1.88 system.api.php
--- modules/system/system.api.php	15 Oct 2009 14:07:30 -0000	1.88
+++ modules/system/system.api.php	15 Oct 2009 15:57:05 -0000
@@ -118,6 +118,23 @@ function hook_entity_info_alter(&$entity
 }
 
 /**
+ * Act on entities when loaded.
+ *
+ * This is a generic load hook called for all entity types loaded via the
+ * entity API.
+ *
+ * @param $entities
+ *   The entities keyed by entity ID.
+ * @param $type
+ *   The type of entities being loaded (i.e. node, user, comment).
+ */
+function hook_entity_load($entities, $type) {
+  foreach ($entities as $entity) {
+    $entity->foo = mymodule_add_something($entity, $entity_type);
+  }
+}
+
+/**
  * Perform periodic actions.
  *
  * This hook will only be called if cron.php is run (e.g. by crontab).
Index: modules/taxonomy/taxonomy.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.test,v
retrieving revision 1.52
diff -u -p -r1.52 taxonomy.test
--- modules/taxonomy/taxonomy.test	15 Oct 2009 14:34:07 -0000	1.52
+++ modules/taxonomy/taxonomy.test	15 Oct 2009 15:57:08 -0000
@@ -757,7 +757,7 @@ class TaxonomyTermFieldTestCase extends 
     $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), t('Entity was created'));
 
     // Display the object.
-    $entity = field_test_entity_load($id);
+    $entity = field_test_entity_test_load($id);
     $entity->content = field_attach_view($entity_type, $entity);
     $this->content = drupal_render($entity->content);
     $this->assertText($term->name, t('Term name is displayed'));
