Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#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's profile johnh10 Owned by: peterwilsoncc's profile peterwilsoncc
Milestone: 5.3 Priority: normal
Severity: normal Version: 5.1
Component: Comments Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

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:

<?php
                $link = sprintf(
                        "<a rel='nofollow' class='comment-reply-link' href='%s' %s aria-label='%s'>%s</a>",
                        esc_url(
                                add_query_arg(
                                        array(
                                                'replytocom'      => $comment->comment_ID,
                                                'unapproved'      => false,
                                                'moderation-hash' => false,
                                        ),
                                        get_permalink($post->ID)
                                )
                        ) . '#' . $args['respond_id'],
                        $data_attribute_string,
                        esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ),
                        $args['reply_text']
                );

After adding the get_permalink line it works as expected.

Attachments (3)

47174.diff (491 bytes) - added by justinahinon 6 years ago.
47174.2.diff (1.9 KB) - added by donmhico 5 years ago.
Added unit test.
47174.3.diff (1.8 KB) - added by peterwilsoncc 5 years ago.

Download all attachments as: .zip

Change History (10)

#1 @justinahinon
6 years 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.

@justinahinon
6 years ago

#2 @earnjam
6 years 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
6 years ago

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

@donmhico
5 years ago

Added unit test.

#4 @donmhico
5 years 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
5 years 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
5 years ago

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

#7 @peterwilsoncc
5 years 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.