From af212ad9b3f6c7a354151b4e7e8cece7e00b1398 Mon Sep 17 00:00:00 2001 From: TimothyBlynJacobs Date: Sun, 31 Oct 2021 06:07:56 +0000 Subject: [PATCH] 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 --- wp-includes/rest-api/class-wp-rest-server.php | 1 + wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/wp-includes/rest-api/class-wp-rest-server.php b/wp-includes/rest-api/class-wp-rest-server.php index 55f0ce6fc8..e2999f7c82 100644 --- a/wp-includes/rest-api/class-wp-rest-server.php +++ b/wp-includes/rest-api/class-wp-rest-server.php @@ -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, diff --git a/wp-includes/version.php b/wp-includes/version.php index 60d7f4b0c6..bbd1304e92 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.