[wp-trac] [WordPress Trac] #31086: Uniform results for getting terms

WordPress Trac noreply at wordpress.org
Wed Jan 21 15:19:53 UTC 2015


#31086: Uniform results for getting terms
------------------------------------------+--------------------
 Reporter:  joshlevinson                  |       Owner:
     Type:  defect (bug)                  |      Status:  new
 Priority:  normal                        |   Milestone:  4.2
Component:  Taxonomy                      |     Version:  trunk
 Severity:  normal                        |  Resolution:
 Keywords:  needs-patch needs-unit-tests  |     Focuses:
------------------------------------------+--------------------
Changes (by boonebgorges):

 * keywords:   => needs-patch needs-unit-tests
 * milestone:  Awaiting Review => 4.2


Comment:

 joshlevinson - Many thanks for the ticket, and for the detective work.
 Normally, I'd be a bit nervous about removing meaningful array keys like
 this, but the fact that `get_the_terms()` is returning inconsistent
 results for cached vs uncached terms makes me think that no one could be
 using these indexes in any meaningful way - their debugging would quickly
 lead them to ditch it in favor of `wp_list_pluck( $terms, 'term_id' )` or
 whatever.

 term_id indexing in the taxonomy cache was introduced in [5555], when term
 caching was first introduced. (It was called `category_id` at the time :)
 )

 The `array_values()` fix you've suggested doesn't really go to the heart
 of the problem. I'd suggest instead changing `update_object_term_cache()`
 so that it doesn't index by term_id in this loop
 https://core.trac.wordpress.org/browser/trunk/src/wp-
 includes/taxonomy.php#L3737. This won't fix the problem for data that is
 already cached, but that's a temporary issue. For completeness's sake,
 it'd be nice to have unit tests that show that results of
 `get_the_terms()` are zero-indexed for both cached and uncached terms.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31086#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list