WordPress.org

Make WordPress Core

Opened 7 months ago

Closed 5 months ago

#42597 closed defect (bug) (fixed)

Term Already Exists Error No Longer Returns Term ID

Reported by: coleh Owned by: rachelbaker
Milestone: 4.9.3 Priority: normal
Severity: normal Version: 4.9
Component: REST API Keywords: has-patch has-unit-tests fixed-major
Focuses: Cc:

Description

This ticket #41370 appears to have changed the error response for when a term already exists.

However, it used to return the term ID of the term inside the error data.

It no longer does that. The reason for needing this is if you are attempting to create a post on another site that has a category/tag that already exists, it will return the term ID so you can use that inside the post creation to properly set the taxonomy IDs of the newly created post.

Attachments (2)

42597.diff (1.8 KB) - added by shooper 7 months ago.
Adds term_id of existing term to response. Includes unit tests.
42597.1.diff (1.8 KB) - added by rachelbaker 7 months ago.
Updated patch to reduce overhead in the test_create_item_term_already_exists method

Download all attachments as: .zip

Change History (14)

#1 @swissspidy
7 months ago

#42600 was marked as a duplicate.

@shooper
7 months ago

Adds term_id of existing term to response. Includes unit tests.

#2 @shooper
7 months ago

  • Keywords has-patch has-unit-tests added

@swissspidy Good catch on the duplicate, didn't notice this ticket.

Patch added that adds term_id to the 'data' array in the response. This isn't 100% backward compatible with 4.8.3, but I don't think we can change the HTTP status code in the response without adding the 'status' key w/ add_data(). Open to suggestions.

This ticket was mentioned in Slack in #core-restapi by timothybjacobs. View the logs.


7 months ago

@rachelbaker
7 months ago

Updated patch to reduce overhead in the test_create_item_term_already_exists method

#4 @rachelbaker
7 months ago

  • Owner set to rachelbaker
  • Resolution set to fixed
  • Status changed from new to closed

In 42350:

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.

#5 @netweb
7 months ago

  • Milestone changed from Awaiting Review to 5.0

#6 @coleh
7 months ago

Thanks for addressing this issue.

Any reason this is being slated for 5.0 which could be months away? This was a feature that worked previous to 4.9 and now doesn't work properly with 4.9 and could potentially break applications using the REST API as ours is broken. I am just trying to understand why this wouldn't have been included with 4.9.1 or a next minor release to fix a very small bug that broke functionality with the API response?

#7 @shooper
7 months ago

Agree with @coleh, this ticket addressed a regression. @netweb Could we target this fix for the next minor release?

#8 @netweb
7 months ago

  • Milestone changed from 5.0 to 4.9.2
  • Resolution fixed deleted
  • Status changed from closed to reopened

Makes sense @shooper and @shooper, moving to the 4.9.2 milestone and reopening for backporting

#9 @obenland
6 months ago

  • Keywords fixed-major added

#10 @dd32
5 months ago

  • Milestone changed from 4.9.2 to 4.9.3

Bumping to 4.9.3 due to 4.9.2s release

This ticket was mentioned in Slack in #core by desrosj. View the logs.


5 months ago

#12 @jorbin
5 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 42578:

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

Merges [42350] into 4.9

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

Note: See TracTickets for help on using tickets.