REST API: Correct HTTP status code in error for requests to create a duplicate term.

The 409 error code is intended for situations where it is expected that the user will resolve the conflict and resubmit the same request. We use 400 error codes for other routes when a duplicate request is made. The 400 status code tells the user they need to modify their request for it to be successful.

Props shooper.
Fixes #42781. See #41370.
Built from https://develop.svn.wordpress.org/trunk@42354


git-svn-id: http://core.svn.wordpress.org/trunk@42183 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Rachel Baker 2017-12-03 19:09:49 +00:00
parent 9ff1fb5af1
commit 0e656c1a10
2 changed files with 2 additions and 2 deletions

View File

@ -419,7 +419,7 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
if ( $term_id = $term->get_error_data( 'term_exists' ) ) {
$existing_term = get_term( $term_id, $this->taxonomy );
$term->add_data( $existing_term->term_id, 'term_exists' );
$term->add_data( array( 'status' => 409, 'term_id' => $term_id ) );
$term->add_data( array( 'status' => 400, 'term_id' => $term_id ) );
}
return $term;

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.0-alpha-42353';
$wp_version = '5.0-alpha-42354';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.