Commit a2efa15f authored by lussoluca's avatar lussoluca Committed by willzyx

Issue #1891070 by maat8, lussoluca: Remove devel_rebuild_node_comment_statistics from the codebase

parent 6e4f4c6b
......@@ -552,46 +552,6 @@ function ddebug_backtrace($return = FALSE, $pop = 0, $options = DEBUG_BACKTRACE_
}
}
/*
* Migration-related functions.
*/
/**
* Regenerates the data in node_comment_statistics table.
* Technique - http://www.artfulsoftware.com/infotree/queries.php?&bw=1280#101
*
* @return void
*/
function devel_rebuild_node_comment_statistics() {
// Empty table.
db_truncate('node_comment_statistics')->execute();
// TODO: DBTNG. Ignore keyword is Mysql only? Is only used in the rare case
// when two comments on the same node share same timestamp.
$sql = "
INSERT IGNORE INTO {node_comment_statistics} (nid, cid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) (
SELECT c.nid, c.cid, c.created, c.name, c.uid, c2.comment_count FROM {comment} c
JOIN (
SELECT c.nid, MAX(c.created) AS created, COUNT(*) AS comment_count FROM {comment} c WHERE status = 1 GROUP BY c.nid
) AS c2 ON c.nid = c2.nid AND c.created = c2.created
)";
db_query($sql, array(':published' => CommentInterface::PUBLISHED));
// 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', 'changed', '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', array('return' => Database::RETURN_NULL))
->from($query)
->execute();
}
/**
* Implements hook_form_FORM_ID_alter().
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment