- Timestamp:
- 02/02/2021 05:26:06 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/class-wp-rest-request.php
r49955 r50150 803 803 $order = $this->get_parameter_order(); 804 804 805 $invalid_params = array(); 805 $invalid_params = array(); 806 $invalid_details = array(); 806 807 807 808 foreach ( $order as $type ) { … … 826 827 } 827 828 829 /** @var mixed|WP_Error $sanitized_value */ 828 830 $sanitized_value = call_user_func( $param_args['sanitize_callback'], $value, $this, $key ); 829 831 830 832 if ( is_wp_error( $sanitized_value ) ) { 831 $invalid_params[ $key ] = $sanitized_value->get_error_message(); 833 $invalid_params[ $key ] = implode( ' ', $sanitized_value->get_error_messages() ); 834 $invalid_details[ $key ] = rest_convert_error_to_response( $sanitized_value )->get_data(); 832 835 } else { 833 836 $this->params[ $type ][ $key ] = $sanitized_value; … … 842 845 sprintf( __( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), 843 846 array( 844 'status' => 400, 845 'params' => $invalid_params, 847 'status' => 400, 848 'params' => $invalid_params, 849 'details' => $invalid_details, 846 850 ) 847 851 ); … … 895 899 * This is done after required checking as required checking is cheaper. 896 900 */ 897 $invalid_params = array(); 901 $invalid_params = array(); 902 $invalid_details = array(); 898 903 899 904 foreach ( $args as $key => $arg ) { … … 902 907 903 908 if ( null !== $param && ! empty( $arg['validate_callback'] ) ) { 909 /** @var bool|\WP_Error $valid_check */ 904 910 $valid_check = call_user_func( $arg['validate_callback'], $param, $this, $key ); 905 911 … … 909 915 910 916 if ( is_wp_error( $valid_check ) ) { 911 $invalid_params[ $key ] = $valid_check->get_error_message(); 917 $invalid_params[ $key ] = implode( ' ', $valid_check->get_error_messages() ); 918 $invalid_details[ $key ] = rest_convert_error_to_response( $valid_check )->get_data(); 912 919 } 913 920 } … … 920 927 sprintf( __( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), 921 928 array( 922 'status' => 400, 923 'params' => $invalid_params, 929 'status' => 400, 930 'params' => $invalid_params, 931 'details' => $invalid_details, 924 932 ) 925 933 );
Note: See TracChangeset
for help on using the changeset viewer.