REST API: Only provide JSON error code on PHP 5.3+.

json_last_error() was only added to PHP 5.3.0, so we can't provide the information for older versions.

See #38547.

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


git-svn-id: http://core.svn.wordpress.org/trunk@39053 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan McCue 2016-11-03 04:57:30 +00:00
parent 63ba4592e1
commit 721cf281a3
2 changed files with 6 additions and 3 deletions

View File

@ -683,9 +683,12 @@ class WP_REST_Request implements ArrayAccess {
$error_data = array( $error_data = array(
'status' => WP_Http::BAD_REQUEST, 'status' => WP_Http::BAD_REQUEST,
'json_error_code' => json_last_error(),
'json_error_message' => json_last_error_msg(),
); );
if ( function_exists( 'json_last_error' ) ) {
$error_data['json_error_code'] = json_last_error();
$error_data['json_error_message'] = json_last_error_msg();
}
return new WP_Error( 'rest_invalid_json', __( 'Invalid JSON body passed.' ), $error_data ); return new WP_Error( 'rest_invalid_json', __( 'Invalid JSON body passed.' ), $error_data );
} }

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.7-beta1-39110'; $wp_version = '4.7-beta1-39111';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.