#45163 closed enhancement (fixed)
get_term_by() should accept ID as a field
Reported by: | emrikol | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Taxonomy | Keywords: | has-patch has-unit-tests 2nd-opinion |
Focuses: | Cc: |
Description
Similar to ticket #33869 and get_user_by()
, get_term_by()
should accept either ID
or id
for the $field
argument.
This helps keep consistency between similar functions that use similar arguments.
Attachments (3)
Change History (14)
#1
@
6 years ago
- Component changed from General to Taxonomy
- Keywords has-patch needs-unit-tests added
- Milestone changed from Awaiting Review to Future Release
This ticket was mentioned in Slack in #core by esoj. View the logs.
4 years ago
#8
@
4 years ago
- Keywords revert added
- Resolution fixed deleted
- Status changed from closed to reopened
- Type changed from defect (bug) to enhancement
Unlike the users and posts table, the terms table has no ID column. From that point it doesn’t make sense to adopt the behavior from the other functions. Since terms have actually two IDs we shouldn’t really promote another alias for an existing alias id
for term_id
.
Voting for a revert of [47865].
#9
@
4 years ago
- Keywords 2nd-opinion added
Indeed, id
is already an alias for term_id
here, and ID
is now a second alias. While that seems a bit redundant, it adds some consistency between the APIs despite the underlying database structure differences. I can see it both ways and don't necessarily object to the change. Would appreciate more opinions here.
The documentation, however, needs some adjustment for consistency with that of get_user_by()
.
Patch against trunk for get_term_by