WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/24/2020 10:44:38 PM (11 months ago)
Author:
TimothyBlynJacobs
Message:

REST API, XML-RPC: Synchronise empty comment content checks.

The REST API and XML-RPC now uses the same detection methodology for empty comment content as wp_handle_comment_submission(). Specifically, comments now have their content trimmed and '0' is allowed.

Props jaswrks, rmccue, dd32, rachelbaker, Cawa-93, aduth, TimothyBlynJacobs.
Fixes #43177.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r49271 r49303  
    38773877        }
    38783878
    3879         if ( empty( $content_struct['content'] ) ) {
    3880             return new IXR_Error( 403, __( 'Comment is required.' ) );
    3881         }
    3882 
    38833879        $comment = array(
    38843880            'comment_post_ID' => $post_id,
    3885             'comment_content' => $content_struct['content'],
     3881            'comment_content' => trim( $content_struct['content'] ),
    38863882        );
    38873883
     
    39233919
    39243920        $comment['comment_parent'] = isset( $content_struct['comment_parent'] ) ? absint( $content_struct['comment_parent'] ) : 0;
     3921
     3922        /** This filter is documented in wp-includes/comment.php */
     3923        $allow_empty = apply_filters( 'allow_empty_comment', false, $comment );
     3924
     3925        if ( ! $allow_empty && '' === $comment['comment_content'] ) {
     3926            return new IXR_Error( 403, __( 'Comment is required.' ) );
     3927        }
    39253928
    39263929        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
Note: See TracChangeset for help on using the changeset viewer.