Make WordPress Core


Ignore:
Timestamp:
05/16/2023 12:29:34 PM (3 years ago)
Author:
spacedmonkey
Message:

Taxonomy: Do not prime term meta in wp_get_object_terms.

Passing update_term_meta_cache argument value false by default resulting in get_terms to not prime the term meta cache in wp_get_object_terms. Priming of term meta is not needed in this context.

Props spacedmonkey, rutviksavsani.
Fixes #57701.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term/getTheTerms.php

    r55745 r55759  
    196196    /**
    197197     * @ticket 36814
    198      */
    199     public function test_uncached_terms_should_be_primed_with_a_single_query() {
     198     * @ticket 57701
     199     */
     200    public function test_uncached_terms_should_not_be_primed_with_a_single_query_by_default() {
    200201        register_taxonomy( 'wptests_tax', 'post' );
    201202
     
    214215        $this->assertSameSets( $terms, wp_list_pluck( $found, 'term_id' ) );
    215216
    216         $num_queries++;
    217         $this->assertSame( $num_queries, get_num_queries() );
    218 
     217        // Two extra queries are expected as the cache is not primed and hence terms need to be queried.
     218        $this->assertSame( 1, get_num_queries() - $num_queries );
    219219    }
    220220
Note: See TracChangeset for help on using the changeset viewer.