function comment_enable

Same name and namespace in other branches
  1. 6.x drupal-6.x/modules/comment/comment.install \comment_enable()

Implements hook_enable().

Archivo

drupal-7.x/modules/comment/comment.install, line 35
Install, update and uninstall functions for the comment module.

Código

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