You are here

function comment_enable in Drupal 7

Same name and namespace in other branches
  1. 5 modules/comment/comment.install \comment_enable()
  2. 6 modules/comment/comment.install \comment_enable()

Implements hook_enable().

File

modules/comment/comment.install, line 32
Install, update and uninstall functions for the comment module.

Code

function comment_enable() {

  // Insert records into the node_comment_statistics for nodes that are missing.
  $query = db_select('node', 'n');
  $query
    ->leftJoin('node_comment_statistics', 'ncs', 'ncs.nid = n.nid');
  $query
    ->addField('n', 'created', 'last_comment_timestamp');
  $query
    ->addField('n', 'uid', 'last_comment_uid');
  $query
    ->addField('n', 'nid');
  $query
    ->addExpression('0', 'comment_count');
  $query
    ->addExpression('NULL', 'last_comment_name');
  $query
    ->isNull('ncs.comment_count');
  db_insert('node_comment_statistics')
    ->from($query)
    ->execute();
}