Hi, I made this post here because I have a problem with my "Recent comments" block on my site, http://www.intothespirit.com
As you can see, some comments listed there have no names, so there is only "posted by ...". I noticed that this happens when a user edits a comment. Here is the code from the comment.module:
/** line 156
* Implementation of hook_block().
*
* Generates a block with the most recent comments.
*/
function comment_block($op = 'list', $delta = 0) {
if ($op == 'list') {
$blocks[0]['info'] = t('Recent comments');
return $blocks;
}
else if ($op == 'view' && user_access('access comments')) {
$result = db_query_range(db_rewrite_sql('SELECT c.nid, c.* FROM {comments} c WHERE c.status = 0 ORDER BY c.timestamp DESC', 'c'), 0, 5);
$items = array();
while ($comment = db_fetch_object($result)) {
$result2 = db_query('SELECT name FROM {comments} WHERE cid='.$comment->cid);
$comment_user = db_fetch_object($result2);
$items[] = l($comment->subject . '', 'node/'. $comment->nid, NULL, NULL, 'comment-'. $comment->cid) .'<br /> posted by <b>'. $comment_user->name . '</b><br />'. t('%time ago', array('%time' => format_interval(time() - $comment->timestamp)));
}
$block['subject'] = t('Recent comments');
$block['content'] = theme('item_list', $items);
return $block;
}
}
Anyone got an ide