Opened 19 months ago

Closed 19 months ago

Last modified 19 months ago

#19029 closed defect (bug) (fixed)

Delete Permanently comments one by one in Spams or Trash increases counter

Reported by: hebbet Owned by: duck_
Priority: normal Milestone: 3.3
Component: Comments Version: 3.0.5
Severity: normal Keywords: has-patch
Cc: kpayne@…

Description

Repro:

*Have eg 25 Comments in Spam.

*Delete five using Delete Permanently one by one.

What happens:

After you one comment counter is correct (24), but when you delete the second, third... comment counter will increase (25, 26, 27, 28, 29)

Attachments (1)

19029.diff (1.5 KB) - added by duck_ 19 months ago.

Download all attachments as: .zip

Change History (14)

  • Summary changed from Delete Permanently one comment in Spams increases counter to Delete Permanently comments one by one in Spams or Trash increases counter

also happens in Trash

  • Keywords reporter-feedback added

Can you reproduce it in 3.3 beta 2 or trunk version? I can't either in 3.2.1 nor trunk.

i meant the items counter under the search box.

it also happens in 3.3 beta 2

  • Keywords needs-patch added; reporter-feedback removed

Ok, now I see it.

Duplicate: #18963

After a bit of investigation the problem appears to be in delAfter in edit-comments.js. I notice that getUpdate('trash') returns -1. So, total = total - spam - trash actually increments the total count. This incremented total is sent on successive delete requests and the visible numbers start going wrong too.

if ( $(settings.target).parent().is('span.' + s) )
  return 1;
else if ( $('#' + settings.element).is('.' + s) )
  return -1;

the first branch isn't entered as $(settings.target).parent() is a span with class "delete" and not "trash". The return -1 branch is as the comment row does have the trash class.

  • Version changed from 3.2.1 to 3.0.5

Present in 3.0.6 too (not checked earlier). You must have paginated the comments list for it to apply then so that "Displaying 1-x of y" is shown.

comment:7 follow-up: ↓ 8   thee1719 months ago

You do not have to have paginate on. It will do the same thing to "x Items" on the upper right, the number in brackets in "Spam (36) | Trash (0)" count properly.

comment:8 in reply to: ↑ 7   duck_19 months ago

Replying to thee17:

You do not have to have paginate on. It will do the same thing to "x Items" on the upper right, the number in brackets in "Spam (36) | Trash (0)" count properly.

I was talking about reproducing in 3.0.6 and possibly earlier. For 3.2.x and trunk you're correct reproduction doesn't need pagination.

duck_19 months ago

  • Keywords has-patch added; needs-patch removed

Attached 19029.diff.

The fix for the bug described is the logic change to updating the total value at the bottom. We want to decrement the displayed total unless a trash/spam is being undone.

Also removed the span.total-type-count update code as "total-type-count" isn't referenced anywhere else in WordPress core. The total updates now take place inline using .displaying-num. Updated the comment accompanying updateTotalCount() accordingly.

  • Cc kpayne@… added

19029.diff works for me. One note: Clicking too fast results in the count getting out of sync. screenshot.

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

In [19068]:

Stop an incorrect comment total being displayed when a trashed/spammed comment is deleted or restored. Fixes #19029.

Also only run getUpdate() when necessary and remove reference to non-existent "span.total-type-count".

  • Milestone changed from Awaiting Review to 3.3

related #17275

Note: See TracTickets for help on using tickets.