Skip to content

Commit a13dc85

Browse files
REST API: Refactor rest_sanitize_schema_properties to improve OPTIONS request handling
1 parent abb58b6 commit a13dc85

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/wp-includes/rest-api.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,15 @@ function register_rest_field( $object_type, $attribute, $args = array() ) {
215215
* @return array|object The sanitized response data.
216216
*/
217217
function rest_sanitize_schema_properties( $data, $server, $request ) {
218-
if ( $request->get_method() !== 'OPTIONS' ) {
219-
return $data;
220-
}
221-
222-
if ( ! is_array( $data ) || ! isset( $data['schema'] ) ) {
223-
return $data;
218+
if (
219+
$request->get_method() === 'OPTIONS' &&
220+
is_array( $data ) &&
221+
isset( $data['schema'] ) &&
222+
is_array( $data['schema'] )
223+
) {
224+
$data['schema'] = rest_sanitize_schema_properties_recursive( $data['schema'] );
224225
}
225226

226-
$data['schema'] = rest_sanitize_schema_properties_recursive( $data['schema'] );
227-
228227
return $data;
229228
}
230229

0 commit comments

Comments
 (0)