mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-12-06 12:51:58 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@51960 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -6,6 +6,7 @@ class Spy_REST_Server extends WP_REST_Server {
|
||||
public $sent_body = '';
|
||||
public $last_request = null;
|
||||
public $override_by_default = false;
|
||||
public $status = null;
|
||||
|
||||
/**
|
||||
* Gets the raw $endpoints data from the server.
|
||||
@@ -37,6 +38,14 @@ class Spy_REST_Server extends WP_REST_Server {
|
||||
$this->sent_headers[ $header ] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores last set status.
|
||||
* @param int $code HTTP status.
|
||||
*/
|
||||
public function set_status( $status ) {
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a header from the list of sent headers.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user