@@ -313,7 +313,7 @@ public function setup_inputs( $method = null, $url = null, $post_body = null ) {
313
313
$ this ->content_type = filter_var ( wp_unslash ( $ _SERVER ['HTTP_CONTENT_TYPE ' ] ) );
314
314
} elseif ( ! empty ( $ _SERVER ['CONTENT_TYPE ' ] ) ) {
315
315
$ this ->content_type = filter_var ( wp_unslash ( $ _SERVER ['CONTENT_TYPE ' ] ) );
316
- } elseif ( '{ ' === $ this ->post_body [0 ] ) {
316
+ } elseif ( isset ( $ this -> post_body [ 0 ] ) && '{ ' === $ this ->post_body [0 ] ) {
317
317
$ this ->content_type = 'application/json ' ;
318
318
} else {
319
319
$ this ->content_type = 'application/x-www-form-urlencoded ' ;
@@ -424,9 +424,10 @@ public function serve( $exit = true ) {
424
424
425
425
// Normalize path and extract API version.
426
426
$ this ->path = untrailingslashit ( $ this ->path );
427
- preg_match ( '#^/rest/v(\d+(\.\d+)*)# ' , $ this ->path , $ matches );
428
- $ this ->path = substr ( $ this ->path , strlen ( $ matches [0 ] ) );
429
- $ this ->version = $ matches [1 ];
427
+ if ( preg_match ( '#^/rest/v(\d+(\.\d+)*)# ' , $ this ->path , $ matches ) ) {
428
+ $ this ->path = substr ( $ this ->path , strlen ( $ matches [0 ] ) );
429
+ $ this ->version = $ matches [1 ];
430
+ }
430
431
431
432
$ allowed_methods = array ( 'GET ' , 'POST ' );
432
433
$ four_oh_five = false ;
@@ -741,7 +742,7 @@ public static function serializable_error( $error ) {
741
742
742
743
$ status_code = $ error ->get_error_data ();
743
744
744
- if ( is_array ( $ status_code ) ) {
745
+ if ( is_array ( $ status_code ) && isset ( $ status_code [ ' status_code ' ] ) ) {
745
746
$ status_code = $ status_code ['status_code ' ];
746
747
}
747
748
0 commit comments