WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#36742 closed defect (bug) (fixed)

Comments List Table: Comment date doesn't get linked on status change via Ajax

Reported by: ocean90 Owned by: ocean90
Milestone: 4.6 Priority: normal
Severity: normal Version: 4.5
Component: Comments Keywords: has-patch
Focuses: Cc:
PR Number:

Description

Since [36521] the comment date gets only linked if the comment status is initially approved.

If you update the comment status via the Approve action link the date remains unlinked, means you don't have a way to view the comment on the front end.

Attachments (4)

36742.patch (2.7 KB) - added by imath 4 years ago.
36742.2.patch (2.7 KB) - added by adamsilverstein 4 years ago.
36742.3.diff (607 bytes) - added by rachelbaker 4 years ago.
Add check that res.responses is not undefined to prevent console error
36742.4.diff (1.2 KB) - added by ocean90 4 years ago.

Download all attachments as: .zip

Change History (16)

#1 @rachelbaker
4 years ago

  • Owner set to rachelbaker
  • Status changed from new to assigned

Unless you refresh... but yes should be fixed.

#2 @imath
4 years ago

  • Keywords has-patch added; needs-patch removed

If you update the comment status via the Approve action link the date remains unlinked, means you don't have a way to view the comment on the front end.

The opposite is also happening, if you unapprove a comment, the link stays..

I suggest 36742.patch to fix the issue.

@imath
4 years ago

#3 @adamsilverstein
4 years ago

I tested the 36742.patch and verified it works as expected. when the ajax request is sent, an approved message will return with the correct comment link as part of the data. The JS then recognizes the presence of the returned link and properly links the date field in the corresponding row.

Here is a screencast of the fix in action:

http://cl.ly/2w241U0l1Q2T/Screen%20Recording%202016-06-16%20at%2009.40%20PM.gif

I can see a little room for cleanup in the patch, update incoming.

#4 @adamsilverstein
4 years ago

@imath thanks for your patch, this works well in my testing.

In 36742.2.patch I did a tiny bit of cleanup: adding a training comma in the array structure as per WP coding standards, adding periods at the end of inline comment statements and also I switched from .html() to .text() where possible because I consider .html() as a possible security vector because it evaluates passed scripts. For this reason I try to use .text whenever possible as a matter of course (even though here I don't think there was a risk).

I'm a little surprised and disgruntled that we have to add the JS to wp-lists.js, but this does appear to be the appropriate spot . Nice work!

#5 @lukecavanagh
4 years ago

The patch applies cleanly and works well.

#6 @imath
4 years ago

yw @adamsilverstein i just tested 36742.2.patch and i confirm it's fixing the issue, many thanks for your improvements.

#7 @rachelbaker
4 years ago

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

In 37743:

Comments: Wrap or unwrap the List Table comment_date as comment status changes via Ajax.

Introduced in [36521].

Fixes #36742.
Props imath, adamsilverstein.

#8 @rachelbaker
4 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

#9 @rachelbaker
4 years ago

While testing a patch for #35501, I found I kept getting the following error in my console log:

wp-lists.js?ver=4.6-beta2-37993-src:310 Uncaught TypeError: Cannot read property '0' of undefined

which was happening because line 300 of wp-lists.js has this conditional:

if ( 'undefined' !== typeof res.responses[0].supplemental.comment_link ) {

where somehow I was able to trigger a condition where res = true.

We should, at least, check that res.responses isn't 'undefined' in the same conditional.

Something like this:

if ( 'undefined' !== typeof res.responses && 'undefined' !== typeof res.responses[0].supplemental.comment_link ) {

@rachelbaker
4 years ago

Add check that res.responses is not undefined to prevent console error

#10 @rachelbaker
4 years ago

36742.3.diff contains suggested fix for conditional mentioned in comment:9

Last edited 4 years ago by rachelbaker (previous) (diff)

#11 @rachelbaker
4 years ago

  • Owner changed from rachelbaker to ocean90
  • Status changed from reopened to assigned

@ocean90 can you check my logic in 36742.3.diff, I don't have enough of a grasp on the logic in source:trunk/src/wp-includes/js/wp-lists.js to know if this patch covers all the use-cases.

@ocean90
4 years ago

#12 @ocean90
4 years ago

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

Fixed in [38050].

Note: See TracTickets for help on using tickets.