Make WordPress Core


Ignore:
Timestamp:
05/16/2023 12:29:34 PM (17 months 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/wpGetObjectTerms.php

    r55745 r55759  
    615615    /**
    616616     * @ticket 10142
    617      */
    618     public function test_termmeta_cache_should_be_lazy_loaded_by_default() {
     617     * @ticket 57701
     618     */
     619    public function test_termmeta_cache_should_not_be_lazy_loaded_by_default() {
    619620        register_taxonomy( 'wptests_tax', 'post' );
    620621        $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
     
    634635        }
    635636
    636         $this->assertSame( $num_queries + 1, get_num_queries() );
     637        // Here we had extra queries as the term meta cache was not primed by default.
     638        $this->assertSame( 3, get_num_queries() - $num_queries );
    637639    }
    638640
Note: See TracChangeset for help on using the changeset viewer.