Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1052
diff -u -p -r1.1052 common.inc
--- includes/common.inc	26 Nov 2009 05:54:48 -0000	1.1052
+++ includes/common.inc	30 Nov 2009 06:24:10 -0000
@@ -6395,6 +6395,18 @@ function entity_get_controller($entity_t
 }
 
 /**
+ * Invoke hook_ENTITY_prepare_view() and field_attach_prepare_view().
+ *
+ * @param $entities
+ *   The entity objects which are being prepared for view.
+ * @param $entity_type
+ *   The type of entity, i.e. 'node', 'user'.
+ */
+function entity_prepare_view($entities, $entity_type) {
+  module_invoke_all('entity_prepare_view', $entities, $entity_type);
+}
+
+/**
  * Performs one or more XML-RPC request(s).
  *
  * @param $url
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.810
diff -u -p -r1.810 comment.module
--- modules/comment/comment.module	28 Nov 2009 16:41:19 -0000	1.810
+++ modules/comment/comment.module	30 Nov 2009 06:24:10 -0000
@@ -840,6 +840,7 @@ function comment_build_content($comment,
 
   // Build fields content.
   field_attach_prepare_view('comment', array($comment->cid => $comment), $build_mode);
+  entity_prepare_view(array($comment->cid => $comment), 'comment');
   $comment->content += field_attach_view('comment', $comment, $build_mode);
 
   if (empty($comment->in_preview)) {
@@ -931,6 +932,7 @@ function comment_links($comment, $node) 
  */
 function comment_build_multiple($comments, $node, $build_mode = 'full', $weight = 0) {
   field_attach_prepare_view('comment', $comments, $build_mode);
+  entity_prepare_view($comments, 'comment');
 
   $build = array(
     '#sorted' => TRUE,
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1170
diff -u -p -r1.1170 node.module
--- modules/node/node.module	29 Nov 2009 10:43:53 -0000	1.1170
+++ modules/node/node.module	30 Nov 2009 06:24:12 -0000
@@ -2109,6 +2109,7 @@ function node_feed($nids = FALSE, $chann
  */
 function node_build_multiple($nodes, $build_mode = 'teaser', $weight = 0) {
   field_attach_prepare_view('node', $nodes, $build_mode);
+  entity_prepare_view($nodes, 'node');
   $build = array();
   foreach ($nodes as $node) {
     $build['nodes'][$node->nid] = node_build($node, $build_mode);
Index: modules/rdf/rdf.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/rdf/rdf.module,v
retrieving revision 1.9
diff -u -p -r1.9 rdf.module
--- modules/rdf/rdf.module	26 Nov 2009 05:54:48 -0000	1.9
+++ modules/rdf/rdf.module	30 Nov 2009 06:24:12 -0000
@@ -554,6 +554,25 @@ function rdf_preprocess_field_formatter_
 }
 
 /**
+ * Implements hook_entity_prepare_view().
+ */
+function rdf_entity_prepare_view($entities, $entity_type) {
+  $uids = array();
+  // In the case of both nodes and comments, the full $account object for the
+  // author is needed in rdf_preprocess_username(), however this is not
+  // available from node_load() or comment_load(). If the users are loaded
+  // for the first time in rdf_preprocess_username() this will issue an
+  // individual user_load() for each account, so pre-load the users needed
+  // here where we can take advantage of user_load_multiple().
+  if ($entity_type == 'node' || $entity_type == 'comment') {
+    foreach ($entities as $entity) {
+      $uids[$entity->uid] = $entity->uid;
+    }
+    user_load_multiple($uids);
+  }
+}
+
+/**
  * Wraps a template variable in an HTML element with the desired attributes.
  *
  * This is called by rdf_process() shortly before the theme system renders
Index: modules/system/system.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.api.php,v
retrieving revision 1.103
diff -u -p -r1.103 system.api.php
--- modules/system/system.api.php	15 Nov 2009 08:48:39 -0000	1.103
+++ modules/system/system.api.php	30 Nov 2009 06:24:12 -0000
@@ -166,6 +166,29 @@ function hook_entity_load($entities, $ty
 }
 
 /**
+ * Act on entities as they are being prepared for view.
+ *
+ * This module allows you to operate on multiple entities as they are being
+ * prepared for view. It should be used to allow data to be loaded which should
+ * not be part of the object returned from entity_load() - usually when loading
+ * other 'entity' style objects.
+ *
+ * @param $entities
+ *   The entities keyed by entity ID.
+ * @param $type
+ *   The type of entities being loaded (i.e. node, user, comment).
+ */
+function hook_entity_prepare_view($entities, $type) {
+  // Load a specific node into the user object for later theming.
+  if ($type == 'user') {
+    $nodes = mymodule_get_user_nodes(array_keys($entities));
+    foreach ($entities as $uid => $entity) {
+      $entity->user_node = $nodes[$uid];
+    }
+  }
+}
+
+/**
  * Perform periodic actions.
  *
  * This hook will only be called if cron.php is run (e.g. by crontab).
Index: modules/taxonomy/taxonomy.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.pages.inc,v
retrieving revision 1.45
diff -u -p -r1.45 taxonomy.pages.inc
--- modules/taxonomy/taxonomy.pages.inc	13 Nov 2009 09:24:06 -0000	1.45
+++ modules/taxonomy/taxonomy.pages.inc	30 Nov 2009 06:24:12 -0000
@@ -31,6 +31,7 @@ function taxonomy_term_page($term) {
   drupal_add_css(drupal_get_path('module', 'taxonomy') . '/taxonomy.css');
 
   field_attach_prepare_view('taxonomy_term', array($term->tid => $term), 'full');
+  entity_prepare_view(array($term->tid => $term), 'taxonomy_term');
   $build = array();
   $build += field_attach_view('taxonomy_term', $term);
   $build['term_description'] = array(
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.1084
diff -u -p -r1.1084 user.module
--- modules/user/user.module	22 Nov 2009 04:22:54 -0000	1.1084
+++ modules/user/user.module	30 Nov 2009 06:24:13 -0000
@@ -2132,6 +2132,7 @@ function user_build_content($account, $b
 
   // Build fields content.
   field_attach_prepare_view('user', array($account->uid => $account), $build_mode);
+  entity_prepare_view(array($account->uid => $account), 'user');
   $account->content += field_attach_view('user', $account, $build_mode);
 
   // Populate $account->content with a render() array.
