diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-04-16 13:56:45 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-04-16 13:56:45 +0000 |
commit | 11751c151da0dd234fa6f60c42ba9ab40510cf25 (patch) | |
tree | 97cc71a1e739b25a5c5e3338e681e4274ebe3a99 | |
parent | 45dbfaf8164cb175973d8653e3537bd7c2de42ca (diff) | |
download | brdo-11751c151da0dd234fa6f60c42ba9ab40510cf25.tar.gz brdo-11751c151da0dd234fa6f60c42ba9ab40510cf25.tar.bz2 |
- Patch #757288 by catch, jpmckinney: optimize comment_save().
-rw-r--r-- | modules/comment/comment.module | 24 |
1 files changed, 14 insertions, 10 deletions
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(); + } } /** |