? cvs_get_vanilla.sh
Index: modules/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node.module,v
retrieving revision 1.485.2.14
diff -u -p -r1.485.2.14 node.module
--- modules/node.module	9 Sep 2005 06:14:24 -0000	1.485.2.14
+++ modules/node.module	23 Feb 2006 15:33:01 -0000
@@ -398,9 +398,6 @@ function node_load($conditions, $revisio
  * Save a node object into the database.
  */
 function node_save($node) {
-  // Fetch fields to save to node table:
-  $fields = node_invoke_nodeapi($node, 'fields');
-
   // Serialize the revisions field:
   if ($node->revisions) {
     $node->revisions = serialize($node->revisions);
@@ -420,11 +417,24 @@ function node_save($node) {
     $node->nid = db_next_id('{node}_nid');
 
     // Prepare the query:
+    $k = $v = $s = array();
     foreach ($node as $key => $value) {
-      if (in_array((string) $key, $fields)) {
-        $k[] = db_escape_string($key);
-        $v[] = $value;
-        $s[] = "'%s'";
+      switch ($key) {
+        case 'nid':     case 'uid':     case 'status':  case 'created':
+        case 'changed': case 'comment': case 'promote': case 'moderate':
+        case 'sticky':  case 'format':
+          // Numeric values
+          $k[] = $key;
+          $v[] = $value;
+          $s[] = '%d';
+          break;
+        case 'type': case 'title':     case 'teaser':
+        case 'body': case 'revisions':
+          // String values
+          $k[] = $key;
+          $v[] = $value;
+          $s[] = "'%s'";
+          break;
       }
     }
 
@@ -442,15 +452,28 @@ function node_save($node) {
     $node->changed = time();
 
     // Prepare the query:
+    $k = $v = array();
     foreach ($node as $key => $value) {
-      if (in_array($key, $fields)) {
-        $q[] = db_escape_string($key) ." = '%s'";
-        $v[] = $value;
+      switch ($key) {
+        case 'nid':     case 'uid':     case 'status':  case 'created':
+        case 'changed': case 'comment': case 'promote': case 'moderate':
+        case 'sticky':  case 'format':
+          // Numeric values
+          $k[] = "$key = %d";
+          $v[] = $value;
+          break;
+        case 'type': case 'title':     case 'teaser':
+        case 'body': case 'revisions':
+          // String values
+          $k[] = "$key = '%s'";
+          $v[] = $value;
+          break;
       }
     }
 
     // Update the node in the database:
-    db_query("UPDATE {node} SET ". implode(', ', $q) ." WHERE nid = '$node->nid'", $v);
+    $v[] = $node->nid;
+    db_query("UPDATE {node} SET ". implode(', ', $k) ." WHERE nid = %d", $v);
 
     // Call the node specific callback (if any):
     node_invoke($node, 'update');
