Make WordPress Core

Ticket #43691: 43691.diff

File 43691.diff, 846 bytes (added by andizer, 4 years ago)
  • src/wp-includes/rest-api/class-wp-rest-server.php

     
    401401                         */
    402402                        $result = apply_filters( 'rest_pre_echo_response', $result, $this, $request );
    403403
     404                        // These are the request types that shouldn't have a response body.
     405                        $bodyless_responses = array( 204, 410, 451 );
     406                        if ( in_array( $code, $bodyless_responses, true ) ) {
     407                                return null;
     408                        }
     409
     410                        if ( $result === null ) {
     411                                _doing_it_wrong( __FUNCTION__, __( 'The response doesn\'t contain a body, which was expected to be there.' ), '5.3' );
     412                        }
     413
    404414                        $result = wp_json_encode( $result );
    405415
    406416                        $json_error_message = $this->get_json_last_error();