Make WordPress Core

Ticket #39578: 39578.diff

File 39578.diff, 736 bytes (added by dspilka, 7 years ago)

Patch to check for WP Error.

  • wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

    diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
    index fbe5259..30466c1 100644
    a b class WP_REST_Comments_Controller extends WP_REST_Controller { 
    560560                 */
    561561                $prepared_comment = apply_filters( 'rest_pre_insert_comment', $prepared_comment, $request );
    562562
     563                if ( is_wp_error( $prepared_comment ) ) {
     564                        return $prepared_comment;
     565        }
     566
    563567                $comment_id = wp_insert_comment( wp_filter_comment( wp_slash( (array) $prepared_comment ) ) );
    564568
    565569                if ( ! $comment_id ) {