Repository navigation
Conversation
When a note is deleted in one session while a reply to it is being written in another, submitting the reply succeeded and announced "Reply added.", but the reply was stored under the trashed note and was no longer shown anywhere in the editor. Reject a note reply whose parent is trashed, marked as spam or permanently deleted, as reactions already are, so the editor shows an error instead of losing the reply. Fixes WordPress#80678.
When a resolved note was deleted in one session, "Reopen & Reply" in another session brought it back: reopening sets the note's status, which moved it out of the trash without the replies trashed along with it, and the new reply was then stored under it. Resolving or editing a deleted note was accepted the same way. Reject any change to a deleted note other than restoring it, so the editor shows an error instead. Undo still restores the note and its replies. See WordPress#80678.
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Updated as activity occurs, without notifying anyone named here. Add the 🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Closes #80678
Stops a note reply, or a change to a note, from being saved after another session has deleted that note. The editor now shows an error and keeps the typed text, instead of reporting success and losing the reply.
Why?
Two editor sessions can disagree about whether a note still exists. When session A submits a reply after session B deleted the note, the request succeeds and the editor announces "Reply added.", but the reply is stored under the trashed note and no longer appears anywhere in the editor.
The same race affects Reopen & Reply on a resolved note. Reopening sets the note's status, which moves the deleted note out of the trash without the replies that were trashed along with it, so the thread comes back with only the new reply. Resolving or editing a deleted note is accepted the same way.
How?
Both changes are in the WordPress 7.2 compat comments controller,
Gutenberg_REST_Comment_Controller_7_2:create_item()rejects a note reply whose parent is trashed, marked as spam, or permanently deleted, with400 rest_comment_invalid_parent. Reactions are already validated this way.update_item()override rejects any change to a trashed or spam note other than restoring it (status: untrashorunspam), with400 rest_comment_invalid_status. The editor's Undo sendsuntrash, so it keeps working.The editor already shows REST error messages in a snackbar, and the note form only clears after a successful save, so no JavaScript changes are needed.
Core's
WP_REST_Comments_Controllerhas the same gap, so this needs a Core backport. Marked as WIP until the Trac ticket, the wordpress-develop PR and thebackport-changelogentry are added.Testing Instructions
Reply to a deleted note
Reopen & Reply on a deleted note
Undo still restores a note
Automated
npm run test:unit:php:base -- --filter WP_Test_REST_Comments_Controller_GutenbergTesting Instructions for Keyboard
There are no UI changes. To check the error with the keyboard, follow the steps above, Tab to the reply field and type the reply, then Tab to Reply (or Reopen & Reply) and press Enter after the note is deleted in the other session. The error appears in a snackbar like other notices, and the reply text stays in the form.
Screenshots or screencast
Use of AI Tools
This PR was authored with Claude Code (Claude Opus 5.5). It reproduced both races in two browser sessions on trunk, wrote the fix and the PHPUnit tests, and drafted this description.