Make WordPress Core

#47174 closed defect (bug) (fixed)

Comment reply links are always to first comment form on a page when $withcomments variable is set to true

Reported by: johnh10 Owned by: peterwilsoncc
Milestone: 5.3 Priority: normal
Severity: normal Version: 5.1
Component: Comments Keywords: has-patch has-unit-tests
Focuses: Cc:


This is a follow-up to #33383.

This bug has returned. I'm not sure which version re-introduced this, but the original fix for #33383 (get_permalink) is missing in the current comments-template.php

The WordPress v5.2 code starting at line 1695 of comments-template.php should be:

                $link = sprintf(
                        "<a rel='nofollow' class='comment-reply-link' href='%s' %s aria-label='%s'>%s</a>",
                                                'replytocom'      => $comment->comment_ID,
                                                'unapproved'      => false,
                                                'moderation-hash' => false,
                        ) . '#' . $args['respond_id'],
                        esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ),

After adding the get_permalink line it works as expected.

Attachments (3)

47174.diff (491 bytes) - added by justinahinon 21 months ago.
47174.2.diff (1.9 KB) - added by donmhico 18 months ago.
Added unit test.
47174.3.diff (1.8 KB) - added by peterwilsoncc 18 months ago.

Download all attachments as: .zip

Change History (10)

#1 @justinahinon
21 months ago

  • Keywords needs-patch needs-testing added
  • Version set to 5.2

Hi @johnh10
Just created a patch for this. I'll track the previous versions changesets to find out where the last one has been removed.

21 months ago

#2 @earnjam
21 months ago

  • Keywords has-patch added; needs-patch removed
  • Version changed from 5.2 to 5.1

Looks like that get_permalink() arg was removed in [42360], so I think this came back in 5.1.

#3 @peterwilsoncc
20 months ago

  • Milestone changed from Awaiting Review to 5.3
  • Owner set to peterwilsoncc
  • Status changed from new to accepted

18 months ago

Added unit test.

#4 @donmhico
18 months ago

  • Keywords needs-testing removed

I added unit test in my patch - 47174.2.diff.

Seeing that this issue "resurfaced", a unit test would be beneficially to prevent this from happening again.

#5 @peterwilsoncc
18 months ago

  • Keywords has-unit-tests added

Thanks @donmhico, you read my mind!

47174.3.diff is almost identical to version 2 with the following changes:

  • some coding standards fixes
  • renamed a couple of variables for clarity to indicate they contain IDs rather than objects

#6 @donmhico
18 months ago

@peterwilsoncc - No problem. I'm reviewing your changes so my future patches would be better. Thank you as well.

#7 @peterwilsoncc
18 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 45787:

Comments: Include post permalink in comment reply link.

Include the post's permalink when generating reply links in get_comment_reply_link() to account for comments displayed on index and archive pages.

This reapplies [32786] which was inadvertently reverted in [42360].

Props justinahinon, donmhico.
See #33383.
Fixes #47174.

Note: See TracTickets for help on using tickets.