diff --git a/wp-includes/rest-api.php b/wp-includes/rest-api.php index 01a1a9a50c..47b922bcd8 100644 --- a/wp-includes/rest-api.php +++ b/wp-includes/rest-api.php @@ -103,6 +103,18 @@ function register_rest_route( $namespace, $route, $args = array(), $override = f '5.5.0' ); } + + if ( count( array_filter( $arg_group['args'], 'is_array' ) ) !== count( $arg_group['args'] ) ) { + _doing_it_wrong( + __FUNCTION__, + sprintf( + /* translators: %s: The REST API route being registered. */ + __( 'REST API $args should be an array of arrays. Non-array value detected for %s.' ), + '' . $clean_namespace . '/' . trim( $route, '/' ) . '' + ), + '6.1.0' + ); + } } $full_route = '/' . $clean_namespace . '/' . trim( $route, '/' ); diff --git a/wp-includes/rest-api/class-wp-rest-server.php b/wp-includes/rest-api/class-wp-rest-server.php index ddb3f6c01b..6327d5a539 100644 --- a/wp-includes/rest-api/class-wp-rest-server.php +++ b/wp-includes/rest-api/class-wp-rest-server.php @@ -1513,6 +1513,11 @@ class WP_REST_Server { $endpoint_data['args'] = array(); foreach ( $callback['args'] as $key => $opts ) { + if ( is_string( $opts ) ) { + $opts = array( $opts => 0 ); + } elseif ( ! is_array( $opts ) ) { + $opts = array(); + } $arg_data = array_intersect_key( $opts, $allowed_schema_keywords ); $arg_data['required'] = ! empty( $opts['required'] ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 1a3576cff5..74f340a574 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-beta2-54338'; +$wp_version = '6.1-beta2-54339'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.