REST API: Return 409 status when attempting to create an existing term.
Fixes an issue where submitting a well-formed request to create a term inappropriately returns a 500 error status if that term already exists. HTTP 5xx error codes should be reserved for unexpected server errors, so "409 Conflict" is a more appropriate response. Props alibasheer, guzzilar, shooper. Fixes #41370. Built from https://develop.svn.wordpress.org/trunk@41737 git-svn-id: http://core.svn.wordpress.org/trunk@41571 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
19e9de3367
commit
fe29c9c881
|
@ -405,6 +405,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 ) );
|
||||
}
|
||||
|
||||
return $term;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.9-alpha-41736';
|
||||
$wp_version = '4.9-alpha-41737';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue