[wp-trac] [WordPress Trac] #64049: REST API: Updating comment via REST does not respect allow_empty_comment filter
WordPress Trac
noreply at wordpress.org
Mon Sep 29 21:11:05 UTC 2025
#64049: REST API: Updating comment via REST does not respect allow_empty_comment
filter
--------------------------+------------------------------
Reporter: kadamwhite | Owner: kadamwhite
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses: rest-api
--------------------------+------------------------------
Changes (by kadamwhite):
* keywords: has-patch has-unit-tests =>
Old description:
> When updating a comment via the REST API we currently fail comment
> updates in the `WP_REST_Comments_Controller::update_item` method if the
> updated content is `empty()`. On REST comment creation and within
> traditional comment updates via `wp_handle_comment_submission` we respect
> the return value of the `allow_empty_comment` filter and permit empty
> comment content when this filter is set.
>
> My understanding of the history here (see #62684) is that allowing
> comments to be edited to become empty permits moderation by allowing
> inappropriate comment content to be deleted without removing the content
> entity itself; or alternatively (and as discussed in #43177) to permit
> comments to be saved which only contain metadata and do not have any
> "content" in the traditional sense.
>
> This may also unblock certain actions for editorial comments within the
> block editor.
New description:
When updating a comment via the REST API we currently fail comment updates
in the `WP_REST_Comments_Controller::update_item` method if the updated
content is `empty()`. On REST comment creation and within traditional
comment updates via `wp_handle_comment_submission` we respect the return
value of the `allow_empty_comment` filter and permit empty comment content
when this filter is set.
My understanding of the history here is that allowing empty comments
permits moderation by allowing inappropriate comment content to be deleted
without removing the content entity itself; or alternatively (and as
discussed in #43177) to permit comments to be saved which only contain
metadata and do not have any "content" in the traditional sense.
This may also unblock certain actions for editorial comments within the
block editor.
--
Comment:
@TimothyBlynJacobs @ryan I've refreshed @adamsilverstein's patch here and
added a test to validate that content updates respect the filter value.
Thoughts?
This was proposed as part of the block editor commenting initiative, but
to me it feels like a good inconsistency to fix regardless of the ongoing
work on that feature.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64049#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list