diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php index 7c62c34fe8..5a844bdfce 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php @@ -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; diff --git a/tests/phpunit/tests/rest-api/rest-categories-controller.php b/tests/phpunit/tests/rest-api/rest-categories-controller.php index 4c1152133e..4161a5bd69 100644 --- a/tests/phpunit/tests/rest-api/rest-categories-controller.php +++ b/tests/phpunit/tests/rest-api/rest-categories-controller.php @@ -702,7 +702,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'name', 'Existing' ); $response = $this->server->dispatch( $request ); - $this->assertEquals( 409, $response->get_status() ); + $this->assertEquals( 400, $response->get_status() ); $data = $response->get_data(); $this->assertEquals( 'term_exists', $data['code'] ); $this->assertEquals( $existing_id, (int) $data['data']['term_id'] );