WordPress.org

Make WordPress Core

Opened 21 months ago

Last modified 20 months ago

#37826 assigned defect (bug)

Can't manage comments of trashed posts

Reported by: swissspidy Owned by: stevenlinx
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Comments Keywords: has-screenshots has-patch good-first-bug
Focuses: Cc:

Description

I noticed two things when managing trashed posts today and thought I'd mention them here.

If you have a trashed post with at least 1 comment or trackback, the speech bubble is being displayed in the list table (as expected). Screenshot:

https://cldup.com/Zr-xujWsOT.png

Now, there are two problems:

  1. When clicking on the bubble to manage the comments of this post, an empty list table is being displayed
  2. The post title above that list table is linked to the post edit screen. When clicking on it, I get a "You can’t edit this item because it is in the Trash" permission error.

Neither of that is expected. Why aren't the comments shown even if they obviously exist (works when restoring)? Why can't I access the edit screen and why does the post title link to it then?

Screenshot:

https://cldup.com/II-QcHLguD.png

Attachments (6)

37826.patch (1.1 KB) - added by stevenlinx 20 months ago.
37826.2.patch (1.1 KB) - added by stevenlinx 20 months ago.
37826.comment-bubble-link-removed.png (11.8 KB) - added by stevenlinx 20 months ago.
37826 (1.8 KB) - added by stevenlinx 20 months ago.
37826.3.patch (1.8 KB) - added by stevenlinx 20 months ago.
37826.comment.php.png (8.0 KB) - added by stevenlinx 20 months ago.

Download all attachments as: .zip

Change History (22)

#1 follow-up: @helen
21 months ago

Huh, that's terrible. What happens to comments of trashed posts that get deleted? They get deleted too?

This ticket was mentioned in Slack in #design by hugobaeta. View the logs.


21 months ago

#3 follow-up: @FolioVision
21 months ago

Should we not just disallow editing of trashed posts? It’s simple and clear. OS’s work similarly (at least Mac does): “You can’t open that item, it’s in the trash."

It seems to me there are two good options for a better user experience:

  1. block the links and give a nice error message.
  2. re-enable editing.

I'd prefer number one to make sure people don't get confused when working with the content and then find it's gone when the trash is emptied (which is why both Windows and Mac won't let you open or work with content in the trash I believe).

What do others think?

#4 in reply to: ↑ 3 @DrewAPicture
21 months ago

Replying to helen:

Huh, that's terrible. What happens to comments of trashed posts that get deleted? They get deleted too?

I'm curious to know this as well.

Replying to FolioVision:

It seems to me there are two good options for a better user experience:

  1. block the links and give a nice error message.
  2. re-enable editing.

What do others think?

I'd probably just not link the bubble at all and skip error messages altogether. Just as you can't edit posts in the trash you shouldn't be able to moderate comments of said posts.

Related to that is whether those comments can also (currently) be moderated outside of this interface. If they can, then we should either look at locking those down as well or unifying the experience across the board to making them moderate-able regardless of the trashed status of the parent post.

#5 in reply to: ↑ 1 ; follow-up: @swissspidy
21 months ago

Replying to helen:

Huh, that's terrible. What happens to comments of trashed posts that get deleted? They get deleted too?

Comments of trashed posts aren't being displayed when on the comments screen. When deleting the post permanently, comments will be deleted permanently too.

Funnily, when I trash a post and go to the edit screen of a single comment for that post, i.e. /wp-admin/comment.php?action=editcomment&c=6, I can still "edit" that comment. To be more precise, I can see the edit form and change any information, but when clicking on "Update", I get redirected to the empty comment list table and the comment wasn't updated at all.

#6 in reply to: ↑ 5 @FolioVision
21 months ago

Funnily, when I trash a post and go to the edit screen of a single comment for that post, i.e. /wp-admin/comment.php?action=editcomment&c=6, I can still "edit" that comment. To be more precise, I can see the edit form and change any information, but when clicking on "Update", I get redirected to the empty comment list table and the comment wasn't updated at all.

Good detective work. Is the consensus we should actively delete these comments? I suppose they could be considered detritus in the database. Nothing serious if there's only a few dozen but if someone is cleaning up a site with posts with hundreds of unwanted comments, the cleanup could matter.

For simplicity's sake, we should probably break the comment cleanup out into another ticket if we agree that we want it too. Our priority here is users access to content in the WordPress trash.

My take is that content in the trash shouldn't be accessible and we just need more elegant notifications (preferably with no screen reload, even for users without javascript enabled).

#7 @swissspidy
21 months ago

Comments should only be deleted when the post is being deleted, otherwise there will be unexpected data loss.

The edit form shouldn't work for comments of trashed posts and the comment bubble shouldn't link to an empty list table.

#8 @swissspidy
20 months ago

  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to Future Release

@stevenlinx
20 months ago

#9 @stevenlinx
20 months ago

  • Keywords has-patch added; needs-patch removed

#10 @swissspidy
20 months ago

Thanks for your patch @stevenlinx! Would you mind uploading a screenshot of the list table with the patch applied so we can easily see the difference?

I'm a bit confused by the Approved comments AND Posts that were trashed. Hyperlinks for editing are removed. comment there. Based on the ticket description hyperlinks are not removed at all. So that might be the actual bug here.

#11 @stevenlinx
20 months ago

@swissspidy

1.) In the screenshot, you can see the "comments bubble" is highlighted (though the mouse pointer is invisible in the screenshot) and the URL does not appear in the web browser status bar, which means no links are applied.

2.) The code comment "Hyperlinks for editing are removed" means the editing hyperlink for the "comments bubble" is removed.

#12 @stevenlinx
20 months ago

@swissspidy

I know you propose making the link of the "comments bubble" under the "trashed" subtab of the "Post" tab leading to a html table that merely displays the comments and no buttons for editing each comment.

I acknowledge the patch is different from what you've proposed and I could have commented first (After I realized what the problem was, I did the patch and submitted too quickly).

When I was evaluating the problem, I concluded that your proposal was based on the wrong assumption. Even if it were correct, it can't be trivially fixed (possibly need further discussion on a separate ticket).

Your assumption was based on the fact that you clicked the link on the "comments bubble" and the resulting page didn't give you the table that you expected, but the core issue is that the "comments bubble" is not supposed to be linked in the first place. You can deduce this design decision from the fact that the post title of a trashed post is currently not linked (this was tested on the latest v4.6.1).

The bug was caused by comments_bubble() function not taking into account that "trashed" posts are not suppose to have hyperlinks. The current code in comments_bubble() simply displays html based on the number of approved comments available, irrespective whether the post in question is already trashed.

1) All properties of a trashed post should be read-only. This was acknowledged by a previous commenter, as akin to a trashed file in the recycle bin of a desktop OS.

2) If you try to create a test post, add a few comments, and trash the post. Then, go direct to the "Comments" tab on the left panel of WP Admin (which loads "edit-comments.php" page), you'll discover the comments you've just added is not displayed anywhere.

On the "edit-comments.php" page, if a post is trashed, then its properties such as comments will not show. By design, the "edit-comments.php" page only displays the "trashed" comments of "active" posts, and not "trashed" posts.

If you go to the "Post" tab, then the "trashed" subtab, and click on the "comments bubble", it loads the same "edit-comments.php" file.

Hence, if you propose to display "trashed" comments of "trashed" posts, you'll be changing the intended role of "edit-comments.php" page. Not to mention you'll have to change how the buttons are displayed, so they're not hyperlinked.

#13 @swissspidy
20 months ago

Well, now your new patch makes more sense. $_GET['post_status'] == 'trash' should be 'trash' === get_post_status( $post_id ) though.

The experience is still not ideal when going to the comments page of that post directly, e.g. /wp-admin/comment.php?action=editcomment&c=6. Doing that should not simply show an empty list table. I didn't propose any specific solution for that as I was merely throwing around some ideas. A simple solution would probably be showing an error message in that scenario.

@stevenlinx
20 months ago

#14 @stevenlinx
20 months ago

@swissspidy

1.) Fixed.

2.) I added code at the top that stops the operation if the post in question is "trashed".

#15 @stevenlinx
20 months ago

  • Keywords good-first-bug removed

#16 @swissspidy
20 months ago

  • Keywords good-first-bug added
  • Owner set to stevenlinx
  • Status changed from new to assigned

@stevenlinx Assigning to you to mark the good-first-bug ticket as claimed.

Note: See TracTickets for help on using tickets.