#35464 closed defect (bug) (fixed)
Documentation of WP_Comment incorrectly describes $comment_author as an ID
Reported by: | meitar | Owned by: | rachelbaker |
---|---|---|---|
Milestone: | 4.5 | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | Comments | Keywords: | has-patch 2nd-opinion |
Focuses: | docs | Cc: |
Description
Super minor, but the docblock for WP_Comment::$comment_author
says it's where the "comment author ID" is stored, but it actually stores the comment author's username. The comment author's ID is actually stored in WP_Comment::$user_id
, whose docblock is correct.
A trivial patch is attached to this ticket to show what I mean.
Attachments (3)
Change History (12)
#1
follow-up:
↓ 2
@
9 years ago
It's not login
. It's the commenter's name. For a logged in commenter it's the display name, AFAIK.
#2
in reply to:
↑ 1
@
9 years ago
Replying to knutsp:
It's not
login
. It's the commenter's name. For a logged in commenter it's the display name, AFAIK.
I don't think that's correct. A simple var_dump($comment->comment_author)
(where $comment
is a WP_Comment
object) returns the user's login name, not the user's display name, even when one is set.
#3
follow-up:
↓ 4
@
9 years ago
Inspecting the database table wp_comments
on my site, where I recently left a comment as a logged in user, I see my display name in the comment_author
column. This display name is different from my login. This name is shown on the front as the name or identity of the commenter.
For not logged in users the property, and the column, contains the name given by the (anonymous) commenter through the comment form field. Such commenter may not have a login at all (not registered).
Did you also dump the user_id
to verify that the comment is from a logged in user?
@
9 years ago
Fix docblock of WP_Comment::$comment_author
to remark that it contains the commenter's display name, not their user ID.
#4
in reply to:
↑ 3
@
9 years ago
- Keywords has-patch added
Replying to knutsp:
Inspecting the database table
wp_comments
on my site, where I recently left a comment as a logged in user, I see my display name in thecomment_author
column. This display name is different from my login. This name is shown on the front as the name or identity of the commenter.
My apologies! You are correct, and I was wrong. I attached a second, corrected diff to this effect.
#5
@
9 years ago
@meitar Hey, thanks for the ticket and the patch. Commenter's that are not logged-in typically have enter their name into an input field that just asks for their name. If a commenter is already logged-in this field doesn't appear. Which means: the comment_author can *either* be the commenter's name or the display name for logged-in users.
@
9 years ago
Docblock with detailed description of what WP_Comment::$comment_author
contains for commenters if they are logged in and if they are not.
#7
@
9 years ago
- Keywords 2nd-opinion added; needs-refresh removed
@rachelbaker Thanks for that more nuanced explanation. The refreshed patch is my attempt at explaining this detail to myself when I inevitably forget it in the future. Let me know if the description in the third patch proposal (attachment:35464.3.diff) is acceptable.
Fix documentation error in
WP_Comment
class.