From ee94a28953d0319edcab83a97975881eb22ad3c9 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Sat, 12 Dec 2015 18:23:28 +0000 Subject: [PATCH] REST API: Improve formatting of failed validation errors. If a validation_callback returns a WP_Error it should give the same response format as if it returned `false`. This makes programmatically reading the validation errors better. Props bradyvercher for initial patch. Fixes #35028. Built from https://develop.svn.wordpress.org/trunk@35890 git-svn-id: http://core.svn.wordpress.org/trunk@35854 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/rest-api/class-wp-rest-request.php | 4 ++-- wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-includes/rest-api/class-wp-rest-request.php b/wp-includes/rest-api/class-wp-rest-request.php index fdf13c46d1..4d4936b5f0 100644 --- a/wp-includes/rest-api/class-wp-rest-request.php +++ b/wp-includes/rest-api/class-wp-rest-request.php @@ -851,13 +851,13 @@ class WP_REST_Request implements ArrayAccess { } if ( is_wp_error( $valid_check ) ) { - $invalid_params[] = sprintf( '%s (%s)', $key, $valid_check->get_error_message() ); + $invalid_params[ $key ] = $valid_check->get_error_message(); } } } if ( $invalid_params ) { - return new WP_Error( 'rest_invalid_param', sprintf( __( 'Invalid parameter(s): %s' ), implode( ', ', $invalid_params ) ), array( 'status' => 400, 'params' => $invalid_params ) ); + return new WP_Error( 'rest_invalid_param', sprintf( __( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), array( 'status' => 400, 'params' => $invalid_params ) ); } return true; diff --git a/wp-includes/version.php b/wp-includes/version.php index a47f0aaded..7964e5d1a9 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.5-alpha-35889'; +$wp_version = '4.5-alpha-35890'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.