You are here

function comment_node_insert in Drupal 7

Implements hook_node_insert().

File

modules/comment/comment.module, line 1305
Enables users to comment on published content.

Code

function comment_node_insert($node) {

  // 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();
  }
}