Repository navigation
Conversation
Another editor session can delete a note while it is still open. A reply submitted afterwards was stored under the trashed note and no longer shown anywhere in the editor. Reopening a resolved note with a reply set the note's status, which moved it out of the trash without the replies trashed along with it. Resolving or editing a deleted note was accepted the same way. Reject a note reply whose parent is trashed, spam or no longer exists, as reactions already are, and reject any change to a trashed or spam note other than restoring it. The editor then shows an error and keeps the typed text, and Undo still restores a deleted note. See #66351.
|
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. |
Another editor session can delete a note while it is still open. The REST API then accepts changes to the deleted note that the editor can no longer show:
201, and the editor announces "Reply added.", but the reply is stored under the trashed note and is not shown anywhere.This PR changes
WP_REST_Comments_Controller:create_item()rejects a note reply whose parent is trashed, spam, or no longer exists, with400 rest_comment_invalid_parent. Reactions are already rejected on a trashed or spam note.update_item()rejects any change to a trashed or spam note other than restoring it (statusofuntrashorunspam), with400 rest_comment_invalid_status. Undo in the editor sendsuntrash, so it keeps working.The editor already shows REST error messages in a snackbar, and keeps the note form's text when a save fails, so no client changes are needed. The same change is in the Gutenberg plugin's 7.2 compat controller: WordPress/gutenberg#85202. Originally reported in WordPress/gutenberg#80678.
Testing Instructions
For Reopen & Reply, resolve the note in A before step 4. Clicking Reopen & Reply after the delete:
The console snippet in the Trac ticket reproduces both in a single session. With this PR, its first request fails with
400.Unit tests:
npm run test:php -- --group 66351Trac ticket: https://core.trac.wordpress.org/ticket/66351
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: In-depth reproduction of both issues, verifying the fix, and assisting with a valid patch and PHPUnit tests.
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.