Repository navigation
Conversation
`wp_trash_comment()` also trashes the child notes of a top-level note, but `wp_untrash_comment()` had no counterpart, so the child notes stayed in the Trash when the parent note was restored. The child notes trashed along with a top-level note are now recorded in the parent's `_wp_trash_meta_children` meta, and only those still in the Trash are restored with it. A child note trashed individually beforehand stays in the Trash. See #66255. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| // Record the children trashed along with the parent, so that they can be restored with it. | ||
| delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_children' ); | ||
| if ( $children ) { | ||
| add_comment_meta( $comment->comment_ID, '_wp_trash_meta_children', $children ); |
There was a problem hiding this comment.
The key follows the existing _wp_trash_meta_* convention for trash-related meta:
_wp_trash_meta_status/_wp_trash_meta_time: Stored on each trashed post or comment itself._wp_trash_meta_comments_status: Stored on a trashed post bywp_trash_post_comments()to record the comments trashed along with it, and deleted bywp_untrash_post_comments()once they are restored.
Unlike _wp_trash_meta_comments_status, it only stores the IDs, since each child note's original status is already stored in its own _wp_trash_meta_status by wp_trash_comment().
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
8d7eb73 to
b1e42dd
Compare
…sh tests. Co-Authored-By: Claude <noreply@anthropic.com>
peterwilsoncc
left a comment
There was a problem hiding this comment.
Some additional unit tests to ensure the following would be dandy:
- the trashing of parent comments of other types- comments, pings, etc- does not modify the children
- other comment types don't get the meta data
- other comment types don't modify children on untrashing
Co-Authored-By: Claude <noreply@anthropic.com>
|
Thanks for the feedback! I've added some tests. As a result, the PR now includes the following new tests:
|
peterwilsoncc
left a comment
There was a problem hiding this comment.
Thanks @t-hamano, these additional tests look good to me.
Approving for you to commit after the merge conflicts are resolved.
# Conflicts: # src/wp-includes/comment.php # tests/phpunit/tests/comment.php
Restoring a top-level note from the Trash now also restores the child notes that were trashed along with it. Child notes the user trashed individually before trashing the parent stay in the Trash. Developed in: #14044 Props wildworks, mukesh27, peterwilsoncc. Fixes #66255. git-svn-id: https://develop.svn.wordpress.org/trunk@64684 602fd350-edb4-49c9-b593-d223f7449a82
Restoring a top-level note from the Trash now also restores the child notes that were trashed along with it. Child notes the user trashed individually before trashing the parent stay in the Trash. Developed in: WordPress/wordpress-develop#14044 Props wildworks, mukesh27, peterwilsoncc. Fixes #66255. Built from https://develop.svn.wordpress.org/trunk@64684 git-svn-id: http://core.svn.wordpress.org/trunk@63834 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Backport of WordPress/gutenberg#84100
wp_trash_comment()also trashes the child notes of a top-level note, butwp_untrash_comment()has no counterpart, so the child notes stay in the Trash when the parent note is restored.Following
wp_trash_post_comments()/wp_untrash_post_comments():_wp_trash_meta_childrenmeta.A child note the user trashed individually before trashing the parent is not recorded, so it stays in the Trash.
Trac ticket: https://core.trac.wordpress.org/ticket/66255
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Implementation and tests; reviewed and verified by me.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
🤖 Generated with Claude Code