mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
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:
parent
9ff1fb5af1
commit
0e656c1a10
@ -419,7 +419,7 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
|
|||||||
if ( $term_id = $term->get_error_data( 'term_exists' ) ) {
|
if ( $term_id = $term->get_error_data( 'term_exists' ) ) {
|
||||||
$existing_term = get_term( $term_id, $this->taxonomy );
|
$existing_term = get_term( $term_id, $this->taxonomy );
|
||||||
$term->add_data( $existing_term->term_id, 'term_exists' );
|
$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;
|
return $term;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user