Make WordPress Core


Ignore:
Timestamp:
10/31/2021 06:06:02 AM (3 years ago)
Author:
TimothyBlynJacobs
Message:

REST API: Send a 500 status code when JSON encoding fails.

Previously, a 200 status code would be sent despite the 500 status code present in the response body.

Props hermpheus, lalitjalandhar.
Fixes #53056.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/spy-rest-server.php

    r47253 r51960  
    77    public $last_request        = null;
    88    public $override_by_default = false;
     9    public $status              = null;
    910
    1011    /**
     
    3637    public function send_header( $header, $value ) {
    3738        $this->sent_headers[ $header ] = $value;
     39    }
     40
     41    /**
     42     * Stores last set status.
     43     * @param int $code HTTP status.
     44     */
     45    public function set_status( $status ) {
     46        $this->status = $status;
    3847    }
    3948
Note: See TracChangeset for help on using the changeset viewer.