WordPress.org

Make WordPress Core

Opened 6 months ago

Closed 2 months ago

Last modified 13 days ago

#53678 closed defect (bug) (fixed)

Comment author filter is not applied to comment reply

Reported by: mjulian7 Owned by: SergeyBiryukov
Milestone: 5.9 Priority: normal
Severity: minor Version:
Component: Comments Keywords: has-patch commit
Focuses: Cc:

Description

comment_form_title() uses get_comment_author() to display the comment author, however get_comment_reply_link() uses $comment->comment_author.

Therefore the latter does not apply the get_comment_author filter.

Change History (9)

This ticket was mentioned in PR #1501 on WordPress/wordpress-develop by mjulian87.


6 months ago

  • Keywords has-patch added

Trac ticket: https://core.trac.wordpress.org/ticket/53678

get_comment_author filters are applied in the output of the comment form, but not during the comment reply.

get_comment_author( $comment->comment_ID ) should be used instead of $comment->comment_author inside get_comment_reply_link() function.

This ticket was mentioned in PR #1501 on WordPress/wordpress-develop by mjulian87.


6 months ago

Trac ticket: https://core.trac.wordpress.org/ticket/53678

get_comment_author filters are applied in the output of the comment form, but not during the comment reply.

get_comment_author( $comment->comment_ID ) should be used instead of $comment->comment_author inside get_comment_reply_link() function.

#3 @SergeyBiryukov
6 months ago

  • Component changed from General to Comments
  • Milestone changed from Awaiting Review to 5.9

#4 @audrasjb
3 months ago

Patch looks good to me, I tested it applying this hook:

function wpcore_get_comment_author( $author, $comment_ID, $comment ) {
    return 'testing - ' . $author;
}
add_filter( 'get_comment_author', 'wpcore_get_comment_author', 10, 3 );

And it works fine on my side.

This ticket was mentioned in Slack in #core by chaion07. View the logs.


2 months ago

#6 @chaion07
2 months ago

  • Keywords commit added

Hello @mjulian7! Thank you for reporting this. We discussed this ticket during a recent bug-scrub session for 5.9 and based on the feedback we're marking this for 'Commit'. Cheers!

Props: @audrasjb & @hellofromTonya

#7 @SergeyBiryukov
2 months ago

Hi there, welcome to WordPress Trac! Thanks for the PR.

This looks good, but we should pass the full comment object to get_comment_author(), instead of just the ID, same as other comment template functions do:

  • comment_author()
  • get_comment_author_link()
  • get_comment_text()
  • comment_form_title()

That way, it can reuse the existing object and avoid an creating a new WP_Comment instance, with an extra cache lookup or database query. See [34039], [34042], [34129], and other similar changes on #33638 for more context.

#8 @SergeyBiryukov
2 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 52154:

Comments: Use get_comment_author() to retrieve the comment author name in get_comment_reply_link().

This ensures that the get_comment_author filter is applied to the comment author name as expected.

Follow-up to [29822], [47506].

Props mjulian7, audrasjb, chaion07, hellofromTonya, SergeyBiryukov.
Fixes #53678.

Note: See TracTickets for help on using tickets.