Make WordPress Core


Ignore:
Timestamp:
04/21/2023 09:22:04 AM (3 years ago)
Author:
spacedmonkey
Message:

Taxonomy: Always lazily load term meta.

In [34529] introduced lazy loading of term meta. However, this was only in the context of WP_Query. Other parts of the codebase, like WP_Term_Query did not lazily load term meta. In this change, calls to update_termmeta_cache are now replaced with wp_lazyload_term_meta, that instead of priming term meta caches, just adds them to the queue to be primed it ever called. This results in far less database queries, as there a number of places where term meta is being primed unnecessarily and never used. Adding everything to the term meta queue, also means that if term meta is used, that is all loaded in a single database / cache call.

Props spacedmonkey, mukesh27, peterwilsoncc.
Fixes #57645.

File:
1 edited

Legend:

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

    r54402 r55671  
    27572757     * @ticket 10142
    27582758     */
    2759     public function test_termmeta_cache_should_be_primed_by_default() {
     2759    public function test_termmeta_cache_should_be_lazy_loaded_by_default() {
    27602760        global $wpdb;
    27612761
     
    27802780        }
    27812781
    2782         $this->assertSame( $num_queries, $wpdb->num_queries );
     2782        $this->assertSame( $num_queries + 1, $wpdb->num_queries );
    27832783    }
    27842784
Note: See TracChangeset for help on using the changeset viewer.