WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 38 hours ago

#37267 new defect (bug)

Don't output a cancel comment reply link if comments aren't threaded

Reported by: henry.wright Owned by:
Milestone: 5.9 Priority: normal
Severity: normal Version: 2.9
Component: Comments Keywords: has-patch has-screenshots needs-unit-tests
Focuses: Cc:

Description

cancel_comment_reply_link() is used inside comment_form() to output a cancel comment reply link. If comments aren't threaded, the cancel comment reply link isn't needed. It currently appears in the HTML source regardless of the status of thread_comments.

Attachments (6)

37267.patch (729 bytes) - added by jignesh.nakrani 5 years ago.
@rachelbaker @henry.wright here is a patch to skip rendering cancel comment reply link if comments aren't threaded.
37267.diff (493 bytes) - added by henry.wright 5 years ago.
37267-1.patch (756 bytes) - added by jignesh.nakrani 19 months ago.
here is a patch to skip rendering cancel comment reply link if comments aren't threaded.
37267.2.diff (741 bytes) - added by audrasjb 4 weeks ago.
Comments: Don’t output the cancel comment link when thread_comments option is not enabled
Capture d’écran 2021-09-26 à 22.59.51.png (247.7 KB) - added by audrasjb 4 weeks ago.
Before patch: the link exists (I removed the display none CSS rule for the example)
Capture d’écran 2021-09-26 à 23.06.12.png (312.9 KB) - added by audrasjb 4 weeks ago.
After patch: the link is not generated at all when threaded_comments option is not enabled

Download all attachments as: .zip

Change History (18)

#1 @rachelbaker
5 years ago

  • Component changed from General to Comments
  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release
  • Version changed from 4.5.3 to 2.9

@henry.wright Thanks for the report. While cancel_comment_reply_link() is always called, if you look at the code in get_cancel_comment_reply_link() the reply link is still output, but hidden unless the replytocom param is set:

$style = isset($_GET['replytocom']) ? '' : ' style="display:none;"';

If threaded comments aren't allowed, I don't see why we need to output anything. Would you be willing to submit a patch?

Introduced in [12810]

@jignesh.nakrani
5 years ago

@rachelbaker @henry.wright here is a patch to skip rendering cancel comment reply link if comments aren't threaded.

#2 @jignesh.nakrani
5 years ago

  • Keywords has-patch added; needs-patch removed

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


5 years ago

#4 @henry.wright
5 years ago

Thanks for the patch. Personally, I'd just bail from the function early if comments aren't threaded.

function get_cancel_comment_reply_link( $text = '' ) {
    if ( ! get_option( 'thread_comments' ) ) {
        return '';
    }
    // Rest of code.
Last edited 5 years ago by henry.wright (previous) (diff)

@henry.wright
5 years ago

#5 @henry.wright
5 years ago

37267.diff is an alternative to @jignesh.nakrani's patch.

37267.diff won't stop cancel_reply_before and cancel_reply_before output, but it will stop the actual cancel comment reply link output.

#6 @desrosj
3 years ago

  • Keywords needs-refresh added

The latest patch no longer applies to trunk.

@jignesh.nakrani
19 months ago

here is a patch to skip rendering cancel comment reply link if comments aren't threaded.

#7 @jignesh.nakrani
19 months ago

  • Keywords needs-refresh removed

37267.diff won't stop cancel_reply_before and cancel_reply_before output, but it will stop the actual cancel comment reply link output.

I think if cancel_reply_link is not being added then we don’t have to print cancel_reply_before and cancel_reply_after

@henrywright @desrosj

#8 @audrasjb
4 weeks ago

  • Keywords needs-refresh added

The patch doesn't apply cleanly against trunk anymore. Refreshing and testing right now.

@audrasjb
4 weeks ago

Comments: Don’t output the cancel comment link when thread_comments option is not enabled

@audrasjb
4 weeks ago

Before patch: the link exists (I removed the display none CSS rule for the example)

@audrasjb
4 weeks ago

After patch: the link is not generated at all when threaded_comments option is not enabled

#9 @audrasjb
4 weeks ago

  • Keywords has-screenshots added; needs-refresh removed
  • Milestone changed from Future Release to 5.9

37267.2.diff refreshes the previous patch against trunk.
It's tested and it work fine: see screenshots above.

Moving for 5.9 consideration.

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


38 hours ago

#11 @audrasjb
38 hours ago

  • Keywords commit added

Marking this for commit as per today's bug scrub

#12 @audrasjb
38 hours ago

  • Keywords needs-unit-tests added; commit removed

Removing commit keyword as it looks like it needs some unit tests

Note: See TracTickets for help on using tickets.