From 11751c151da0dd234fa6f60c42ba9ab40510cf25 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 16 Apr 2010 13:56:45 +0000 Subject: - Patch #757288 by catch, jpmckinney: optimize comment_save(). --- modules/comment/comment.module | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'modules/comment/comment.module') diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 8e2873209..63dd815c7 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -1243,16 +1243,20 @@ function comment_node_prepare($node) { * Implements hook_node_insert(). */ function comment_node_insert($node) { - db_insert('node_comment_statistics') - ->fields(array( - 'nid' => $node->nid, - 'cid' => 0, - 'last_comment_timestamp' => $node->changed, - 'last_comment_name' => NULL, - 'last_comment_uid' => $node->uid, - 'comment_count' => 0, - )) - ->execute(); + // Allow bulk updates and inserts to temporarily disable the + // maintenance of the {node_comment_statistics} table. + if (variable_get('comment_maintain_node_statistics', TRUE)) { + db_insert('node_comment_statistics') + ->fields(array( + 'nid' => $node->nid, + 'cid' => 0, + 'last_comment_timestamp' => $node->changed, + 'last_comment_name' => NULL, + 'last_comment_uid' => $node->uid, + 'comment_count' => 0, + )) + ->execute(); + } } /** -- cgit v1.2.3