? 302438_comment_queued_for_approval_admin_message.patch.1 ? 324313-multiple-node-load.patch ? 324313-multiple-node-load_1.patch ? 336596-whos-online-test-D7_1.patch ? dbtngtest.txt ? load_multiple.patch ? multiple_load.patch ? multiple_load_2.patch ? multiple_load_22.patch ? multiple_load_22.patch.1 ? multiple_load_25.patch ? multiple_load_27.patch ? multiple_load_28.patch ? multiple_load_30.patch ? node_feed_2_0.patch ? node_multiple.patch ? taxonomy_term_count_nodes.patch ? modules/node/node_docs.txt ? modules/taxonomy/taxonomy_docs.txt ? sites/all/modules ? sites/default/files ? sites/default/settings.php Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.998 diff -u -p -r1.998 node.module --- modules/node/node.module 22 Nov 2008 14:09:41 -0000 1.998 +++ modules/node/node.module 27 Nov 2008 15:42:44 -0000 @@ -750,7 +750,7 @@ function node_load($param = array(), $re } $cachable = ($revision == NULL); - $arguments = array(); + $conditions = array(); if (is_numeric($param)) { if ($cachable) { // Is the node statically cached? @@ -758,44 +758,55 @@ function node_load($param = array(), $re return is_object($nodes[$param]) ? clone $nodes[$param] : $nodes[$param]; } } - $cond = 'n.nid = %d'; - $arguments[] = $param; + $conditions['nid'] = $param; } elseif (is_array($param)) { // Turn the conditions into a query. foreach ($param as $key => $value) { - $cond[] = 'n.' . db_escape_table($key) . " = '%s'"; - $arguments[] = $value; + $condtions[$key] = $value; } - $cond = implode(' AND ', $cond); } else { return FALSE; } - - // Retrieve a field list based on the site's schema. - $fields = drupal_schema_fields_sql('node', 'n'); - $fields = array_merge($fields, drupal_schema_fields_sql('node_revisions', 'r')); - $fields = array_merge($fields, array('u.name', 'u.picture', 'u.data')); - // Remove fields not needed in the query: n.vid and r.nid are redundant, - // n.title is unnecessary because the node title comes from the - // node_revisions table. We'll keep r.vid, r.title, and n.nid. - $fields = array_diff($fields, array('n.vid', 'n.title', 'r.nid')); - $fields = implode(', ', $fields); - // Rename timestamp field for clarity. - $fields = str_replace('r.timestamp', 'r.timestamp AS revision_timestamp', $fields); - // Change name of revision uid so it doesn't conflict with n.uid. - $fields = str_replace('r.uid', 'r.uid AS revision_uid', $fields); - - // Retrieve the node. - // No db_rewrite_sql is applied so as to get complete indexing for search. + $query = db_select('node', 'n'); if ($revision) { - array_unshift($arguments, $revision); - $node = db_fetch_object(db_query('SELECT ' . $fields . ' FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = %d WHERE ' . $cond, $arguments)); + $query->join('node_revisions', 'r', 'r.nid = n.nid AND r.vid = :vid', array(':vid' => $revision)); } else { - $node = db_fetch_object(db_query('SELECT ' . $fields . ' FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.vid = n.vid WHERE ' . $cond, $arguments)); + $query->join('node_revisions', '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'); + + // vid and title are provided by node_revisions, so remove them. + unset($node_fields['vid']); + unset($node_fields['title']); + $query->fields('n', $node_fields); + + // Add all fields from the {node_revisions} table. + $node_revision_fields = drupal_schema_fields_sql('node_revisions'); + + // nid is provided by node, so remove it. + unset($node_revision_fields['nid']); + + // Change timestamp to revisions_timestamp before adding it to the query. + unset($node_revision_fields['timestamp']); + $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 ($conditions) { + foreach ($conditions as $field => $value) { + $query->condition('n.' . $field, $value); + } } + $node = $query->execute()->fetch(); if ($node && $node->nid) { // Call the node specific callback (if any) and piggy-back the @@ -818,7 +829,6 @@ function node_load($param = array(), $re return $node; } - /** * Perform validation checks on the given node. */