#30620 closed enhancement (fixed)
get_term_by( 'term_taxonomy_id' ) should NOT require $taxonomy param
Reported by: | joehoyle | Owned by: | boonebgorges |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 3.7 |
Component: | Taxonomy | Keywords: | has-patch |
Focuses: | Cc: |
Description
As we all despise term_ids as it requires a id / taxonomy name pair, it's often nicer to use term_taxonomy_id as it's a much better identifier. This *should* mean it's not necessary to know the taxonomy of a given tt_id (just like one doesn't need to know the post_type of a post to get a post from ID). However, the $taxonomy param to get_term_by() is required.
It seems to be it would be good to change $taxonomy to be not required in the cases of getting by tt_id with get_term_by().
I'll write the code if anyone agrees this makes sense :)
Apologies if that has ben addresses, I'm a bit out of the loop recently.
Attachments (2)
Change History (12)
#1
@
10 years ago
- Summary changed from get_term_by( 'term_taxonomy_id' ) should require $taxonomy param to get_term_by( 'term_taxonomy_id' ) should NOT require $taxonomy param
#4
@
10 years ago
It appears I agreed with this a while ago, wonderboymusic pointed out that we should mind the cache (see #21760).
#5
@
10 years ago
- Keywords has-patch added
- Milestone changed from Awaiting Review to Future Release
30620.diff - we would probably need to add tt_ids to a cache that is does not have tax in its group hash
#6
@
9 years ago
- Milestone changed from Future Release to 4.4
- Owner set to boonebgorges
- Status changed from new to assigned
If the spirit moves you
#8
follow-up:
↓ 9
@
9 years ago
FYI, this change to get_term_by
broke the REST API, since we relying on the check. We've fixed it, but might be worth noting in a field notes post for others that it might break.
(Accidentally commented on #14162, but that's unrelated.)
#9
in reply to:
↑ 8
@
9 years ago
Replying to rmccue:
FYI, this change to
get_term_by
broke the REST API, since we relying on the check. We've fixed it, but might be worth noting in a field notes post for others that it might break.
(Accidentally commented on #14162, but that's unrelated.)
Thanks for the note. I'll note the change in the taxonomy field notes for 4.4. But the new behavior is probably the correct one: if you are passing a 'term_taxonomy_id', you're likely doing it for the explicit reason that you want to avoid the 'taxonomy' table join, which means that you've already done your homework.
Given <https://make.wordpress.org/core/2013/07/28/potential-roadmap-for-taxonomy-meta-and-post-relationships/> and <https://make.wordpress.org/core/2014/11/12/an-update-on-the-taxonomy-roadmap/> I think this is already underway :)