From 0d8b0a5319e216bedd86441af47c77c4bcdd18e6 Mon Sep 17 00:00:00 2001
From: Marco Martins <marcomartins@fimdalinha.com>
Date: Thu, 14 Jun 2018 16:16:02 +0300
Subject: [PATCH] 44360 - wp-includes/rest-api/
---
wp-includes/rest-api/class-wp-rest-request.php | 16 +++++++++++++---
.../endpoints/class-wp-rest-comments-controller.php | 10 +++++++++-
.../endpoints/class-wp-rest-settings-controller.php | 13 +++++++++++--
3 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/wp-includes/rest-api/class-wp-rest-request.php b/wp-includes/rest-api/class-wp-rest-request.php
index f4981e9..eddfc54 100644
a
|
b
|
class WP_REST_Request implements ArrayAccess { |
802 | 802 | |
803 | 803 | if ( $invalid_params ) { |
804 | 804 | return new WP_Error( |
805 | | 'rest_invalid_param', sprintf( __( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), array( |
| 805 | 'rest_invalid_param', sprintf( |
| 806 | /* translators: %s is the list of invalid parameters */ |
| 807 | __( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) |
| 808 | ), array( |
806 | 809 | 'status' => 400, |
807 | 810 | 'params' => $invalid_params, |
808 | 811 | ) |
… |
… |
class WP_REST_Request implements ArrayAccess { |
845 | 848 | |
846 | 849 | if ( ! empty( $required ) ) { |
847 | 850 | return new WP_Error( |
848 | | 'rest_missing_callback_param', sprintf( __( 'Missing parameter(s): %s' ), implode( ', ', $required ) ), array( |
| 851 | 'rest_missing_callback_param', sprintf( |
| 852 | /* translators: %s is the list of required parameters */ |
| 853 | __( 'Missing parameter(s): %s' ), implode( ', ', $required ) |
| 854 | ), array( |
849 | 855 | 'status' => 400, |
850 | 856 | 'params' => $required, |
851 | 857 | ) |
… |
… |
class WP_REST_Request implements ArrayAccess { |
878 | 884 | |
879 | 885 | if ( $invalid_params ) { |
880 | 886 | return new WP_Error( |
881 | | 'rest_invalid_param', sprintf( __( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), array( |
| 887 | 'rest_invalid_param', sprintf( |
| 888 | /* translators: %s is the list of invalid parameters */ |
| 889 | __( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) |
| 890 | ), |
| 891 | array( |
882 | 892 | 'status' => 400, |
883 | 893 | 'params' => $invalid_params, |
884 | 894 | ) |
diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
index 021c43c..3e67ade 100644
a
|
b
|
class WP_REST_Comments_Controller extends WP_REST_Controller { |
153 | 153 | } |
154 | 154 | |
155 | 155 | if ( ! empty( $forbidden_params ) ) { |
156 | | return new WP_Error( 'rest_forbidden_param', sprintf( __( 'Query parameter not permitted: %s' ), implode( ', ', $forbidden_params ) ), array( 'status' => rest_authorization_required_code() ) ); |
| 156 | return new WP_Error( 'rest_forbidden_param', |
| 157 | sprintf( |
| 158 | /* translators: %s is the list of forbidden parameters */ |
| 159 | __( 'Query parameter not permitted: %s' ), implode( ', ', $forbidden_params ) |
| 160 | ), |
| 161 | array( |
| 162 | 'status' => rest_authorization_required_code(), |
| 163 | ) |
| 164 | ); |
157 | 165 | } |
158 | 166 | } |
159 | 167 | |
diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php
index 1a38261..d8e0e63 100644
a
|
b
|
class WP_REST_Settings_Controller extends WP_REST_Controller { |
185 | 185 | * delete all options that have invalid values from the |
186 | 186 | * database. |
187 | 187 | */ |
188 | | if ( is_wp_error( rest_validate_value_from_schema( get_option( $args['option_name'], false ), $args['schema'] ) ) ) { |
| 188 | if ( is_wp_error( rest_validate_value_from_schema( get_option( $args['option_name'], false ), $args['schema'] ) ) ) |
| 189 | { |
189 | 190 | return new WP_Error( |
190 | | 'rest_invalid_stored_value', sprintf( __( 'The %s property has an invalid stored value, and cannot be updated to null.' ), $name ), array( 'status' => 500 ) |
| 191 | 'rest_invalid_stored_value', |
| 192 | sprintf( |
| 193 | /* translators: %s is the property name */ |
| 194 | __( 'The %s property has an invalid stored value, and cannot be updated to null.' ), |
| 195 | $name |
| 196 | ), |
| 197 | array( |
| 198 | 'status' => 500, |
| 199 | ) |
191 | 200 | ); |
192 | 201 | } |
193 | 202 | |