Changeset 47122 for trunk/src/wp-includes/rest-api/class-wp-rest-server.php
- Timestamp:
- 01/29/2020 12:43:23 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/class-wp-rest-server.php
r47060 r47122 415 415 416 416 $json_error_message = $this->get_json_last_error(); 417 417 418 if ( $json_error_message ) { 418 $json_error_obj = new WP_Error( 'rest_encode_error', $json_error_message, array( 'status' => 500 ) ); 419 $result = $this->error_to_response( $json_error_obj ); 420 $result = wp_json_encode( $result->data[0] ); 419 $json_error_obj = new WP_Error( 420 'rest_encode_error', 421 $json_error_message, 422 array( 'status' => 500 ) 423 ); 424 425 $result = $this->error_to_response( $json_error_obj ); 426 $result = wp_json_encode( $result->data[0] ); 421 427 } 422 428 … … 429 435 } 430 436 } 437 431 438 return null; 432 439 } … … 454 461 $data['_links'] = $links; 455 462 } 463 456 464 if ( $embed ) { 457 465 // Determine if this is a numeric array. … … 479 487 public static function get_response_links( $response ) { 480 488 $links = $response->get_links(); 489 481 490 if ( empty( $links ) ) { 482 491 return array(); … … 847 856 848 857 $args = array(); 858 849 859 foreach ( $matches as $param => $value ) { 850 860 if ( ! is_int( $param ) ) { … … 867 877 868 878 if ( ! is_callable( $callback ) ) { 869 $response = new WP_Error( 'rest_invalid_handler', __( 'The handler for the route is invalid' ), array( 'status' => 500 ) ); 879 $response = new WP_Error( 880 'rest_invalid_handler', 881 __( 'The handler for the route is invalid' ), 882 array( 'status' => 500 ) 883 ); 870 884 } 871 885 … … 924 938 $response = $permission; 925 939 } elseif ( false === $permission || null === $permission ) { 926 $response = new WP_Error( 'rest_forbidden', __( 'Sorry, you are not allowed to do that.' ), array( 'status' => rest_authorization_required_code() ) ); 940 $response = new WP_Error( 941 'rest_forbidden', 942 __( 'Sorry, you are not allowed to do that.' ), 943 array( 'status' => rest_authorization_required_code() ) 944 ); 927 945 } 928 946 } … … 988 1006 } 989 1007 990 return $this->error_to_response( new WP_Error( 'rest_no_route', __( 'No route was found matching the URL and request method' ), array( 'status' => 404 ) ) ); 1008 return $this->error_to_response( 1009 new WP_Error( 1010 'rest_no_route', 1011 __( 'No route was found matching the URL and request method' ), 1012 array( 'status' => 404 ) 1013 ) 1014 ); 991 1015 } 992 1016 … … 1070 1094 1071 1095 if ( ! isset( $this->namespaces[ $namespace ] ) ) { 1072 return new WP_Error( 'rest_invalid_namespace', __( 'The specified namespace could not be found.' ), array( 'status' => 404 ) ); 1096 return new WP_Error( 1097 'rest_invalid_namespace', 1098 __( 'The specified namespace could not be found.' ), 1099 array( 'status' => 404 ) 1100 ); 1073 1101 } 1074 1102 … … 1187 1215 if ( isset( $callback['args'] ) ) { 1188 1216 $endpoint_data['args'] = array(); 1217 1189 1218 foreach ( $callback['args'] as $key => $opts ) { 1190 1219 $arg_data = array(
Note: See TracChangeset
for help on using the changeset viewer.