2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
@@ -371,44 +371,29 @@ function comment_permalink($comment) {
/**
* Find the most recent comments that are available to the current user.
*
* This is done in two steps:
* 1. Query the {node_comment_statistics} table to find n number of nodes that
* have the most recent comments. This table is indexed on
* last_comment_timestamp, thus making it a fast query.
* 2. Load the information from the comments table based on the nids found
* in step 1.
*
* @param integer $number
* (optional) The maximum number of comments to find.
* (optional) The maximum number of comments to find. Defaults to 10.
* @return
* An array of comment objects each containing a nid, subject, cid, created
* and changed, or an empty array if there are no recent comments visible
* to the current user.
* An array of comment objects or an empty array if there are no recent
* comments visible to the current user.
*/
functioncomment_get_recent($number=10){
// Step 1: Select a $number of nodes which have new comments,
// and are visible to the current user.
$nids=db_query_range("SELECT nc.nid FROM {node_comment_statistics} nc WHERE nc.comment_count > 0 ORDER BY nc.last_comment_timestamp DESC",0,$number)->fetchCol();
$comments=array();
if(!empty($nids)){
// Step 2: From among the comments on the nodes selected in the first query,
@@ -1102,6 +1087,7 @@ function comment_node_load($nodes, $types) {
$comments_enabled[]=$node->nid;
}
else{
$node->cid=0;
$node->last_comment_timestamp=$node->created;
$node->last_comment_name='';
$node->comment_count=0;
...
...
@@ -1110,8 +1096,9 @@ function comment_node_load($nodes, $types) {
// For nodes with comments enabled, fetch information from the database.
if(!empty($comments_enabled)){
$result=db_query('SELECT nid, last_comment_timestamp, last_comment_name, comment_count FROM {node_comment_statistics} WHERE nid IN(:comments_enabled)',array(':comments_enabled'=>$comments_enabled));
$result=db_query('SELECT nid, cid, last_comment_timestamp, last_comment_name, comment_count FROM {node_comment_statistics} WHERE nid IN(:comments_enabled)',array(':comments_enabled'=>$comments_enabled));