[wp-trac] [WordPress Trac] #10142: Add metadata support for taxonomy terms

WordPress Trac noreply at wordpress.org
Fri Sep 18 22:27:09 UTC 2015


#10142: Add metadata support for taxonomy terms
-----------------------------+-----------------------
 Reporter:  sirzooro         |       Owner:
     Type:  feature request  |      Status:  reopened
 Priority:  normal           |   Milestone:  4.4
Component:  Taxonomy         |     Version:
 Severity:  normal           |  Resolution:
 Keywords:  has-patch        |     Focuses:
-----------------------------+-----------------------
Changes (by boonebgorges):

 * keywords:  needs-patch => has-patch
 * milestone:  Future Release => 4.4


Comment:

 [attachment:10142.diff] is a first pass at implementation. I haven't yet
 done 'meta_query' for `get_terms()` or `wp_get_object_terms()` - I first
 wanted to get the cache implementation straight, and in people's hands for
 feedback.

 Some notes and areas for feedback:
 * Termmeta caches are primed by default in `get_terms()` and
 `wp_get_object_terms()`. In each function, the priming can be disabled
 with `update_term_meta_cache=false`.
 * Inside of the main `$wp_query` loop, termmeta caches are lazy-loaded. It
 works like this. (1) The cache is not primed during the main query
 ('update_term_meta_cache' is set to false in
 `update_object_term_cache()`). (2) When `get_term_meta()` is called within
 the loop, `wp_lazyload_term_meta()` checks to make sure that the terms
 themselves are being primed for the items in the loop. (3) If so, the
 function grabs the IDs of *all* terms associated with *all* posts queried
 in the loop (`$wp_query->posts`), and it primes the termmeta for those
 terms. (4) All subsequent calls to `get_term_meta()` within the loop will
 hit the cache. The purpose of this lazy-loading is to eliminate the
 termmeta query when no termmeta is in fact being used in the loop.
 * `wp_get_object_terms()` only supports termmeta cache priming when
 `fields` is 'term_id', 'all', or 'all_with_object_id'. We need the term_id
 to prime the caches, and with other values of `fields`, it's not
 available. It'd be possible to refactor `wp_get_object_terms()` to make
 the cache priming more flexible, but I don't think it's worth the trouble
 (and the potential performance hits when using, eg, `fields=name`)

 Thoughts and eyeballs are very welcome on this patch. I'll continue to
 plug away at the tax_query implementation.

 ==

 On a somewhat related note, I've almost finished going through all the
 plugins in the repo that reference termmeta in one way or another. The
 results are not as bad as I'd thought - a decent number of plugins that
 have a very small number of users will be affected, but a very small
 number of popular plugins. I'll post results and recommendations soon.
 Based on the results, I think we can shoot for 4.4, if all goes well.

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


More information about the wp-trac mailing list