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.

Built from https://develop.svn.wordpress.org/trunk@51960


git-svn-id: http://core.svn.wordpress.org/trunk@51549 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
TimothyBlynJacobs 2021-10-31 06:07:56 +00:00
parent f76071026b
commit af212ad9b3
2 changed files with 2 additions and 1 deletions

View File

@ -497,6 +497,7 @@ class WP_REST_Server {
$json_error_message = $this->get_json_last_error();
if ( $json_error_message ) {
$this->set_status( 500 );
$json_error_obj = new WP_Error(
'rest_encode_error',
$json_error_message,

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.9-alpha-51959';
$wp_version = '5.9-alpha-51960';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.