[wp-trac] [WordPress Trac] #21760: get_term_by() calls are not cached

WordPress Trac noreply at wordpress.org
Wed Sep 28 13:38:49 UTC 2016


#21760: get_term_by() calls are not cached
----------------------------------------+--------------------------
 Reporter:  wonderboymusic              |       Owner:  ocean90
     Type:  enhancement                 |      Status:  assigned
 Priority:  normal                      |   Milestone:  4.7
Component:  Taxonomy                    |     Version:  2.3
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |     Focuses:  performance
----------------------------------------+--------------------------
Changes (by boonebgorges):

 * keywords:  2nd-opinion has-patch needs-unit-tests => has-patch needs-
     unit-tests
 * owner:  wonderboymusic => ocean90
 * status:  reopened => assigned
 * milestone:  Future Release => 4.7


Comment:

 @ocean90 Thumbs up from me.

 @pento I'd prefer to see those tests rewritten so that they don't directly
 reach into the cache - as you note, cache keys etc are very brittle.
 Butyes, many of them can be repurposed. Tests for invalidation should just
 call `get_term_by()` a second time:

 {{{
 $before = get_term_by( 'slug', 'foo' );
 wp_update_term( $before->term_id, array(
     'name' => 'Bar',
 ) );
 $after = get_term_by( 'slug', 'foo' );
 $this->assertSame( 'Bar', $after->name );
 }}}

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


More information about the wp-trac mailing list