#22801 closed defect (bug) (fixed)
Update documentation on wp_insert_term to state that it will return an error if inserting an existing term.
Reported by: | lgedeon | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 3.7 | Priority: | normal |
Severity: | normal | Version: | 2.3 |
Component: | Inline Docs | Keywords: | has-patch |
Focuses: | Cc: |
Description
phpdoc for wp_insert_term() states:
If both the term id and taxonomy exist previously, then an array will be returned that contains the term id and the contents of what is returned.
However it returns an error object instead. That may have changed with #13481. Anyway, returning an error seems to be an acceptable solution. Although, #16567 might change that a bit.
Should we just adjust the docs to fit the current behavior?
Attachments (4)
Change History (12)
#3
@
11 years ago
- Keywords has-patch added; needs-patch removed
22801.diff rewrites big parts of this docblock for clarity, including the change about returning a WP_Error object mentioned in the ticket description.
Side note: this whole file is slated for a docs review anyway.
#4
@
11 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 25489:
#6
@
11 years ago
Looks like I used 22801.diff in [25489] instead of 22801.2.diff.
22801.4.diff is a partial refresh of 22801.2.diff and 22801.3.diff against trunk, and is my take on further clarifying the error handling.
- A numeric
$term
is allowed, as long as it's not empty. - A non-unique slug is also allowed (it will be regenerated), as long as the name is different.
Inline docs need to better explain the error handling. Function returns WP_Error object.
Current Inline doc: