From 407f641cf352283d6c34b451e3110d827ebf6aa3 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Wed, 18 Nov 2015 18:29:26 +0000 Subject: [PATCH] Update `WP_REST_Response::as_error()` to handle the new format error responses introduced in [35653]. Props danielbachhuber Fixes #34551 Built from https://develop.svn.wordpress.org/trunk@35671 git-svn-id: http://core.svn.wordpress.org/trunk@35635 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/rest-api/class-wp-rest-response.php | 8 ++++++-- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/wp-includes/rest-api/class-wp-rest-response.php b/wp-includes/rest-api/class-wp-rest-response.php index fed1a3124d..db80029038 100644 --- a/wp-includes/rest-api/class-wp-rest-response.php +++ b/wp-includes/rest-api/class-wp-rest-response.php @@ -243,8 +243,12 @@ class WP_REST_Response extends WP_HTTP_Response { $error = new WP_Error; if ( is_array( $this->get_data() ) ) { - foreach ( $this->get_data() as $err ) { - $error->add( $err['code'], $err['message'], $err['data'] ); + $data = $this->get_data(); + $error->add( $data['code'], $data['message'], $data['data'] ); + if ( ! empty( $data['additional_errors'] ) ) { + foreach( $data['additional_errors'] as $err ) { + $error->add( $err['code'], $err['message'], $err['data'] ); + } } } else { $error->add( $this->get_status(), '', array( 'status' => $this->get_status() ) ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 7569830f67..895e7fd606 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-beta4-35670'; +$wp_version = '4.4-beta4-35671'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.