REST API: Add existing term_id to the error data object when attempting to create a duplicate term.

Props shooper, coleh.
Fixes #42597. See #41370.

git-svn-id: https://develop.svn.wordpress.org/trunk@42350 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Rachel Baker
2017-12-03 18:10:05 +00:00
parent 6b325e9916
commit 2b079e098a
2 changed files with 8 additions and 4 deletions
@@ -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->add_data( array( 'status' => 409, 'term_id' => $term_id ) );
}
return $term;