Make WordPress Core


Ignore:
Timestamp:
10/15/2025 08:28:51 PM (3 months ago)
Author:
kadamwhite
Message:

REST API: Allow comment content to be updated to empty when allow_empty_comment filter returns true

This filter was already respected during comment creation, but not updates. This was inconsistent between POST and PUT, and prevented erasing content of moderated comments via the API without deleting the entire object.

Props adamsilverstein, kadamwhite, davidbaumwald, mukesh27, timothyblynjacobs.
Fixes #64049.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

    r59970 r60937  
    860860                return $prepared_args;
    861861            }
    862 
    863             if ( isset( $prepared_args['comment_content'] ) && empty( $prepared_args['comment_content'] ) ) {
     862            if ( ! $this->check_is_comment_content_allowed( $prepared_args ) ) {
    864863                return new WP_Error(
    865864                    'rest_comment_content_invalid',
     
    19041903     */
    19051904    protected function check_is_comment_content_allowed( $prepared_comment ) {
     1905        if ( ! isset( $prepared_comment['comment_content'] ) ) {
     1906            return true;
     1907        }
     1908
    19061909        $check = wp_parse_args(
    19071910            $prepared_comment,
Note: See TracChangeset for help on using the changeset viewer.