diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-03-31 11:49:51 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-03-31 11:49:51 +0000 |
commit | 46f51dec0cc2d21b87962a0eab964b90fe7128d7 (patch) | |
tree | 2828caf195071185100c49f1d04b634e0ba27045 /modules/comment | |
parent | 72bffa027800b07a45046314e85a74341d0f1714 (diff) | |
download | brdo-46f51dec0cc2d21b87962a0eab964b90fe7128d7.tar.gz brdo-46f51dec0cc2d21b87962a0eab964b90fe7128d7.tar.bz2 |
- Patch #757288 by catch: optimize comment_save().
Diffstat (limited to 'modules/comment')
-rw-r--r-- | modules/comment/comment.admin.inc | 2 | ||||
-rw-r--r-- | modules/comment/comment.module | 18 |
2 files changed, 16 insertions, 4 deletions
diff --git a/modules/comment/comment.admin.inc b/modules/comment/comment.admin.inc index b3a6499f8..ddbdc8bed 100644 --- a/modules/comment/comment.admin.inc +++ b/modules/comment/comment.admin.inc @@ -162,7 +162,6 @@ function comment_admin_overview_submit($form, &$form_state) { if ($operation == 'delete') { comment_delete_multiple($cids); - cache_clear_all(); } else { foreach ($cids as $cid => $value) { @@ -179,6 +178,7 @@ function comment_admin_overview_submit($form, &$form_state) { } drupal_set_message(t('The update has been performed.')); $form_state['redirect'] = 'admin/content/comment'; + cache_clear_all(); } /** diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 8ab3925d7..45cccdf8e 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -1418,7 +1418,11 @@ function comment_save($comment) { else { // Add the comment to database. This next section builds the thread field. // Also see the documentation for comment_view(). - if ($comment->pid == 0) { + if (!empty($comment->thread)) { + // Allow calling code to set thread itself. + $thread == $comment->thread; + } + elseif ($comment->pid == 0) { // This is a comment with no parent comment (depth 0): we start // by retrieving the maximum thread level. $max = db_query('SELECT MAX(thread) FROM {comment} WHERE nid = :nid', array(':nid' => $comment->nid))->fetchField(); @@ -1498,8 +1502,6 @@ function comment_save($comment) { entity_invoke('insert', 'comment', $comment); } _comment_update_node_statistics($comment->nid); - // Clear the cache so an anonymous user can see his comment being added. - cache_clear_all(); if ($comment->status == COMMENT_PUBLISHED) { module_invoke_all('comment_publish', $comment); @@ -2132,6 +2134,9 @@ function comment_form_submit($form, &$form_state) { } unset($form_state['rebuild']); $form_state['redirect'] = $redirect; + // Clear the block and page caches so that anonymous users see the comment + // they have posted. + cache_clear_all(); } /** @@ -2283,6 +2288,12 @@ function _comment_per_page() { * - comment_count: the total number of approved/published comments on this node. */ function _comment_update_node_statistics($nid) { + // Allow bulk updates and inserts to temporarily disable the + // maintenance of the {node_comment_statistics} table. + if (!variable_get('comment_maintain_node_statistics', TRUE)) { + return; + } + $count = db_query('SELECT COUNT(cid) FROM {comment} WHERE nid = :nid AND status = :status', array( ':nid' => $nid, ':status' => COMMENT_PUBLISHED, @@ -2496,6 +2507,7 @@ function comment_unpublish_by_keyword_action_submit($form, $form_state) { */ function comment_save_action($comment) { comment_save($comment); + cache_clear_all(); watchdog('action', 'Saved comment %title', array('%title' => $comment->subject)); } |