Hi

A little background: I wanted to change commenters names. Instead of 'Posted by @username', I wanted to use 'Posted by Fullname' (from profile module).

One option for me to do it was overriding theme_comment_submitted(), load content profile node, take Fullname and display it. The problem comes when you have a lot of comments + hight traffic website (too much overhead).

Then I discovered that comments table has a field called 'name' which theoretically was added there to speed up comments rendering and to avoid addition queries and theme_username() calls for each comment.

I thought that I could update that 'name' field using hook_comment() on insert / update and get that stored field inside $comment object later on, but then I discovered this strange logic in the comment.module which prevented me from doing it:

$comment->name = $comment->uid ? $comment->registered_name : $comment->name

Basically it uses username from users table if comment was added by authenticated user and 'name' field from the comments table for anonymous comments, even though that name gets stored for both authenticated and anonymous users.. (basically I got correct name stored in the name field in comments table, but because of that logic the field is not retrievable).

Is there a reason why we use this logic? Why cant we just use $comment->name or wherever is stored in the name field of comments table? That way we could get much more flexible system I think, because it would be possible to modify comment name without doing addition queries during comments display / rendering.

Comments

dixon_’s picture

Version: 7.x-dev » 8.x-dev
andypost’s picture

Status: Active » Closed (cannot reproduce)

You can always change this in your comment* template