Comments: Prevent approved comments from being moved under pending parents#12639
Comments: Prevent approved comments from being moved under pending parents#12639tyxla wants to merge 1 commit into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the 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. |
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. |
There was a problem hiding this comment.
Pull request overview
This PR addresses a threaded-comments integrity issue where an approved comment can end up under an unapproved (pending) parent, which can cause the approved child to disappear from the public threaded comment query. It tightens the Edit Comment UI parent picker and adds server-side validation plus PHPUnit coverage to prevent creating that state.
Changes:
- Restricts the Edit Comment parent dropdown so approved comments only list approved parents, while pending comments may list pending parents.
- Adds server-side validation in
edit_comment()to reject pending parents when the resulting child status is approved. - Extends PHPUnit tests for the parent selector and
edit_comment()validation.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/wp-admin/edit-form-comment.php |
Filters which parent statuses appear in the “In reply to” dropdown based on the edited comment’s approval state. |
src/wp-admin/includes/comment.php |
Adds parent-status validation when editing a comment’s parent, intended to prevent approved children under non-approved parents. |
tests/phpunit/tests/admin/EditFormComment_Test.php |
Adds coverage for excluding pending parents for approved comments and including them for pending comments. |
tests/phpunit/tests/admin/includes/comment/EditComment_Test.php |
Adds tests for rejecting pending parents when the child is (or becomes) approved, and updates the helper to submit status. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…rents. An approved comment must have an approved parent, otherwise it drops out of the public comment list when its pending parent is not loaded. `edit_comment()` now rejects a pending parent whenever the child's final status is approved, using the `comment_approved` value submitted in the same update. The edit screen offers only approved parents when editing an approved comment, while pending comments may still use either. PHPUnit tests cover the parent selector, the server-side validation, and status changes made during the update. Developed in: #12639 Follow-up to [62673]. Props tyxla, youknowriad. Fixes #65688. git-svn-id: https://develop.svn.wordpress.org/trunk@62826 602fd350-edb4-49c9-b593-d223f7449a82
…rents. An approved comment must have an approved parent, otherwise it drops out of the public comment list when its pending parent is not loaded. `edit_comment()` now rejects a pending parent whenever the child's final status is approved, using the `comment_approved` value submitted in the same update. The edit screen offers only approved parents when editing an approved comment, while pending comments may still use either. PHPUnit tests cover the parent selector, the server-side validation, and status changes made during the update. Developed in: WordPress/wordpress-develop#12639 Follow-up to [62673]. Props tyxla, youknowriad. Fixes #65688. Built from https://develop.svn.wordpress.org/trunk@62826 git-svn-id: http://core.svn.wordpress.org/trunk@62106 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Trac ticket: https://core.trac.wordpress.org/ticket/65688
This PR prevents an approved comment from being moved below a pending comment.
When threaded comments are enabled, the public comment query starts with approved top-level comments and then loads their replies. If an approved comment has a pending parent, the parent is not loaded. As a result, the approved child is also missing from the public comment list.
This is a follow-up to #12406 (original ticket 65570).
Changes
Testing
Use of AI Tools
AI assistance: Yes
Tool(s): Codex
Model(s): 5.6 Sol
Used for: Research and coding; final implementation and tests were reviewed and edited by me.