- Patch #461298 by catch: move node_load_multiple() special casing into user_node_load().
parent
0f77f652fa
commit
6e947c65a9
|
@ -842,7 +842,6 @@ function node_load_multiple($nids = array(), $conditions = array(), $reset = FAL
|
|||
else {
|
||||
$query->join('node_revision', 'r', 'r.vid = n.vid');
|
||||
}
|
||||
$query->join('users', 'u', 'u.uid = n.uid');
|
||||
|
||||
// Add fields from the {node} table.
|
||||
$node_fields = drupal_schema_fields_sql('node');
|
||||
|
@ -863,10 +862,6 @@ function node_load_multiple($nids = array(), $conditions = array(), $reset = FAL
|
|||
$query->addField('r', 'timestamp', 'revision_timestamp');
|
||||
$query->fields('r', $node_revision_fields);
|
||||
|
||||
// Add fields from the {users} table.
|
||||
$user_fields = array('name', 'picture', 'data');
|
||||
$query->fields('u', $user_fields);
|
||||
|
||||
if ($nids) {
|
||||
$query->condition('n.nid', $nids, 'IN');
|
||||
}
|
||||
|
|
|
@ -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().
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue