Opened 6 weeks ago
Closed 4 weeks ago
#66255 closed defect (bug) (fixed)
Notes: Restore child notes trashed along with their parent note
| Reported by: | wildworks | Owned by: | wildworks |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2 |
| Component: | Notes | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests gutenberg-merge |
| Cc: | Focuses: |
Description
Gutenberg PR: https://github.com/WordPress/gutenberg/pull/84100
When a top-level note is trashed, wp_trash_comment() also trashes its child notes. However, wp_untrash_comment() has no counterpart for this: when the parent note is restored, its child notes stay in the trash.
To fix this, wp_untrash_comment() needs a counterpart to the child-trashing logic in wp_trash_comment(). The approach can follow the precedent of wp_trash_post_comments() / wp_untrash_post_comments():
- When a top-level note is trashed, store the IDs of the child notes that are not yet in the trash (i.e. the ones being trashed along with the parent) in the parent note's
_wp_trash_meta_childrenmeta. - When the parent note is untrashed, restore only the recorded child notes that are still in the trash, then delete the meta.
Importantly, a child note the user trashed individually before trashing the parent should not be restored when the parent is trashed and then restored. The parent's trash/untrash cycle should only undo what it did itself.
Change History (4)
This ticket was mentioned in PR #14044 on WordPress/wordpress-develop by @wildworks.
6 weeks ago
#1
- Keywords has-patch has-unit-tests added
@wildworks commented on PR #14044:
5 weeks ago
#2
Thanks for the feedback! I've added some tests. As a result, the PR now includes the following new tests:
test_wp_trash_comment_does_not_trash_children_of_other_comment_types: Tests that trashing a top-level comment of a type other than note does not trash its children.test_wp_trash_comment_does_not_record_children_of_other_comment_types: Tests that trashing a top-level comment of a type other than note does not record its children in the_wp_trash_meta_childrenmeta.test_wp_untrash_comment_does_not_modify_children_of_other_comment_types: Tests that untrashing a top-level comment of a type other than note does not modify its children, whether they are in the Trash or held.
Backport of https://github.com/WordPress/gutenberg/pull/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.
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