From 6e947c65a95447eb090c9c0fc6ccf5a93dab23ae Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 30 May 2009 12:14:27 +0000 Subject: - Patch #461298 by catch: move node_load_multiple() special casing into user_node_load(). --- modules/user/user.module | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'modules/user/user.module') diff --git a/modules/user/user.module b/modules/user/user.module index b0186c2bf..460d6858e 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -2672,6 +2672,27 @@ function _user_password_dynamic_validation() { } } +/** + * Implementation of hook_node_load(). + */ +function user_node_load($nodes, $types) { + // Build an array of all uids for node authors, keyed by nid. + $uids = array(); + foreach ($nodes as $nid => $node) { + $uids[$nid] = $node->uid; + } + + // Fetch name, picture, and data for these users. + $user_fields = db_query("SELECT uid, name, picture, data FROM {users} WHERE uid IN (:uids)", array(':uids' => $uids))->fetchAllAssoc('uid'); + + // Add these values back into the node objects. + foreach ($uids as $nid => $uid) { + $nodes[$nid]->name = $user_fields[$uid]->name; + $nodes[$nid]->picture = $user_fields[$uid]->picture; + $nodes[$nid]->data = $user_fields[$uid]->data; + } +} + /** * Implement hook_hook_info(). */ -- cgit v1.2.3