#15530 closed defect (bug) (fixed)
AJAX trashing of comments doesn't update on screen comment count
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.1 | Priority: | normal |
Severity: | minor | Version: | 3.1 |
Component: | Administration | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
When you trash a comment or mark a comment as spam, the "X items" text next to the pagination buttons doesn't update.
Attachments (10)
Change History (31)
#3
@
14 years ago
- Milestone changed from Future Release to 3.1
Per discussion in IRC, this is a regression and should have a bit of love in the context of #16262. I believe garyc40 hopes to handle this.
#8
@
14 years ago
Confused why there's a giant chunk of red in the middle of that patch. There's also now a TODO that mentions pagination links, but it looks like that block of code is supposed to handle pagination links. Would like a second opinion from the JS side as well.
#9
@
14 years ago
That block output the old pagination links ([1] [2] [3] ... type of links), so it's useless in 3.1 anyways. We need to re-do it using WP_List_Table API for pagination link, or recalculate total pages using JS. That's why I put TODO there and delete the whole block.
Perhaps another ticket for restoring the proper pagination links? It's only a minor problem.
#10
@
14 years ago
The problem is a bit more complicated that I thought.
Try these:
- Go to a filter (like Pending or Approved), and trash comment there. The pagination links returned do not include
comment_status
argument (or any arguments for that matter).
- Search something, then delete a comment. The ajax handler does not take argument
s
into account, so wrong total items and total number of pages are returned.
- Go to the last page of the list, delete all comments on that page one by one. The page number becomes to "1 of xx". I think the expected behavior should be redirecting to the new last page.
Working on a patch. Seems like more reds and greens are going to be added to this minor ticket :(
#11
@
14 years ago
Maybe I'm missing something, but why does this need an AJAX call at all? If the item disappears, decrement the appropriate comment counts locally. And if you have comments per page and number of comments, decrement number of comments, divide by cpp, round up, and that's your new number of total pages. Do the opposite for undo.
#13
@
14 years ago
The comment river is not properly refilled if there's a search query ($.query.get()
automatically fill comment_type
with a true
value).
I included a fix for this in garyc40.15530.pagination.diff as well.
#14
@
14 years ago
- Keywords no-really-commit added
Latest patch, 15530.6.diff, is the result of more than four hours of iterations. koopersmith assisted. I also pulled in mdawaffe as he knew the history of the comment counts: [10204/trunk/wp-admin/admin-ajax.php]. As we continued, we noticed particular bugs that garyc40 also ran into, and thus I largely incorporated his fixes where appropriate.
In a nutshell, this patch fixes pagination for comment moderation. Some major points:
- It does not remove a chunk of code from the ajax handler. It keeps the client in sync as before, using the original code with a twist. We now always send an ajax response, rather than a
die( time() )
, but still avoids the comment counts in most situations.
- It avoids touching any list table logic, as we can play dumb and just use the arguments we get from the client.
- It avoids messing with any pagination links themselves, with the exception of the disabled class for the next and last links. Clicking these will redirect you to the last page anyway (even if out of bounds), so I'm perfectly happy with that behavior for 3.1.
#15
@
14 years ago
15530.7.diff includes a change that isn't directly related to everything else here, but is an easy fix. Basically, we stick $.query.get() directly into ajax, but $.query.get() sets comment_type to true
, which then becomes 'true'
, rather than ''
as it should be. Simple check fixes that. $.query might include a way to avoid such casts. I didn't check.
Considering .7 ready for commit.
#17
@
14 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
There is some debug code lurking in the patch that was applied - class-wp-comments-list-table.php
line 51 needs to be culled:
error_log( var_export( $comment_type, true ) );
Sort of related: #6530