WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 2 years ago

#17928 assigned enhancement

When a comment is spammed/trashed, change the parent of it's children

Reported by: Viper007Bond Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.2
Component: Comments Keywords: has-patch
Focuses: Cc:

Description

When removing (spam/trash) a comment that has children, everything goes to hell in terms of hierarchy and you're left with a bunch of orphaned comments.

See two attached images for what currently happens after removing a comment that has children.

When a comment is removed, all immediate children of the comment to be removed should have their parent changed that of the the parent of the comment being removed (or top level if the comment to be removed is top level). Each comment that has it's parent changed then gets that action logged to it's post meta so that it can be moved back in the case of it's previous comment being restored (on post un-delete/spam, find all matching comment metas).

Attachments (3)

before.png (45.0 KB) - added by Viper007Bond 3 years ago.
A bunch of nested comments
after.png (37.8 KB) - added by Viper007Bond 3 years ago.
Note how "Depth = 3, comment #1" is no longer even a child of "Depth = 2, comment #1"
17928.patch (2.7 KB) - added by jakub.tyrcha 3 years ago.

Download all attachments as: .zip

Change History (21)

Viper007Bond3 years ago

A bunch of nested comments

Viper007Bond3 years ago

Note how "Depth = 3, comment #1" is no longer even a child of "Depth = 2, comment #1"

comment:1 Viper007Bond3 years ago

In the screenshotted example, "Depth = 1, comment #1" is the comment that is deleted.

comment:2 scribu3 years ago

Hey, at least they still show up. :)

comment:3 jakub.tyrcha3 years ago

  • Owner set to jakub.tyrcha
  • Status changed from new to assigned

comment:4 azaozz3 years ago

Thinking it would be best if all children (and grandchildren, etc.) of a deleted, spammed or unapproved comment go back to the moderation queue. Tested this a bit and it looks quite weird/meaningless if the main comment is missing but the answers to it (the children) are shown.

comment:5 follow-up: jakub.tyrcha3 years ago

Dammit, I was just finishing writing a fancy graph traversal :P

And what if the parent's moderation is ruled back? All children stay in the queue?

Maybe it would be a good idea to keep the moderated comment blacked out and shown with a moderation notice?

comment:6 in reply to: ↑ 5 azaozz3 years ago

Replying to jakub.tyrcha:

And what if the parent's moderation is ruled back? All children stay in the queue?

IMO they need to get approved again automatically. All this would apply to approved children only of course. Children in the moderation or spam queues should stay there. And here's the next difficulty:

  • parent is approved, has some approved children and some children in moderation
  • then parent gets spammed, all approved children go to moderation (preferably with a note that the parent is unavailable/spam)
  • the user runs into a child comment that was previously in moderation and clicks Approve...

So to avoid confusion this can only be done while moderation comments in hierarchical mode, the flat list we currently have won't work.

comment:7 jakub.tyrcha3 years ago

So I'll submit the first version of the patch for now because it's still better than what we have now and leave the real deal for later ;)

comment:8 scribu3 years ago

Why not move all the children to the trash also? It's the most likely behaviour anyway.

Then, if the user deliberately tries to rescue a child from the trash, it's parent can be set to 0.

comment:9 scribu3 years ago

Obviously, you'd still need to bring back all the children, if the parent is un-trashed.

comment:10 jakub.tyrcha3 years ago

If the user tries to rescue a child from the trash and the parent is set to 0, the problem remains

comment:11 nacin3 years ago

Why not move all the children to the trash also?

Not sure I agree with that paradigm.

comment:12 azaozz3 years ago

Perhaps it would be best to put all approved children in moderation and disable the action links on them. Workflow:

  • a comment is spammed/trashed/unapproved, if it has children the user is prompted what to do with them. Choices: treat as separate comments, spam/trash/unapprove all, do nothing.
  • if "do nothing" is selected, all children are left in moderation until a decision on the parent is made. There is a message "Parent is Spam/In the trash/Unapproved" and the action links on the children are disabled.
  • if the status of the parent is reverted, the status on all children is reverted to the previous.

comment:13 jakub.tyrcha3 years ago

I'm just wondering if "treat as separate comments" vs "do nothing " would be clear for some users

comment:14 azaozz3 years ago

Well, we can word it better. Perhaps "Decide later"?

Also the warning that the parent is in the trash/spam/unapproved can be a link to editing the parent. Of course there are other enhancements to this workflow but for now think we need to set the main part.

Last edited 3 years ago by azaozz (previous) (diff)

jakub.tyrcha3 years ago

comment:15 jakub.tyrcha3 years ago

Just in case anyone want's to play with Viper007Bond's solution ;) I had it done anyway.

BTW, it fixes the TODO: use api thing

Last edited 3 years ago by jakub.tyrcha (previous) (diff)

comment:16 Viper007Bond3 years ago

I'd like to note that this also affects paging. On some of the CNN blogs on WordPress.com for example, a page that would normally have about 15 comments can end up having many hundreds. It makes for some slow page generation times due to the CPU work required to loop through them all.

comment:17 SergeyBiryukov3 years ago

  • Keywords has-patch added; needs-patch removed

comment:18 jane2 years ago

  • Owner jakub.tyrcha deleted

I see everyone's points about the various possible behaviors, but why not take a page from threaded forums who've been doing this way longer than us -- if parent trashed, spammed, deleted, replace it on the page with a placeholder that says it has been removed by an administrator/the site owner. Then the children still show appropriate hierarchy and if there are references to missing parent it will be clear there's something missing and you're not an idiot for not understanding a child comment, and the admin doesn't have to go through the bother of re-approving everything.

Note: See TracTickets for help on using tickets.