Index: modules/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment.module,v
retrieving revision 1.407
diff -u -p -r1.407 comment.module
--- modules/comment.module	15 Dec 2005 16:31:01 -0000	1.407
+++ modules/comment.module	19 Dec 2005 09:17:47 -0000
@@ -620,15 +620,30 @@ function comment_save($edit) {
       }
 
       if ($edit['cid']) {
+        // Form passess date in $edit['date'], we change it to $edit['timestamp'] for easier processing
+        if (isset($edit['date']) && strtotime($edit['date']) > 0) {
+          $edit['timestamp'] = strtotime($edit['date']);
+        }
+
+        // Update only fields that are defined. Prevents e.g. updating timestamp to 0 if not defined.
+        $sqlparts = array('status = %d' => 'status', 'timestamp = %d' => 'timestamp', "subject = '%s'" => 'subject', "comment = '%s'" => 'comment', 'format = %d' => 'format', 'uid = %d' => 'uid', "name = '%s'" => 'name');
+        $sqlfields = array();
+        $sqlvalues = array();
+        foreach ($sqlparts as $sql => $arrayindex) {
+          if (isset($edit[$arrayindex])) {
+            $sqlfields[] = $sql;
+            $sqlvalues[] = $edit[$arrayindex];
+          }
+        }
         // Update the comment in the database.
-        db_query("UPDATE {comments} SET status = '%s', timestamp = %d, subject = '%s', comment = '%s', format = '%s', uid = %d, name = '%s' WHERE cid = %d", $edit['status'], $edit['timestamp'], $edit['subject'], $edit['comment'], $edit['format'], $edit['uid'], $edit['name'], $edit['cid']);
+        $sqlvalues[] = $edit['cid'];
+        db_query("UPDATE {comments} SET ". implode(', ', $sqlfields) ." WHERE cid = %d", $sqlvalues);
 
         _comment_update_node_statistics($edit['nid']);
 
         // Allow modules to respond to the updating of a comment.
         comment_invoke_comment($edit, 'update');
 
-
         // Add an entry to the watchdog log.
         watchdog('content', t('Comment: updated %subject.', array('%subject' => theme('placeholder', $edit['subject']))), WATCHDOG_NOTICE, l(t('view'), 'node/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
       }
