Make WordPress Core


Ignore:
Timestamp:
03/11/2022 11:05:02 AM (3 years ago)
Author:
spacedmonkey
Message:

Taxonomy: Use get_terms instead of a database lookup in term_exists().

Replace raw SQL queries to the terms table, with a call to the get_terms function. Using get_terms means that term_exists is now cached. For developers using term_exists where cache invalidation is disabled, such as importing, a workaround was added to ensure that queries are uncached.

Props Spacedmonkey, boonebgorges, flixos90, peterwilsoncc.
Fixes #36949.

File:
1 edited

Legend:

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

    r52010 r52921  
    448448        $wpdb->update( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => 100005 ), array( 'term_taxonomy_id' => $term_3->term_taxonomy_id ) );
    449449
     450        clean_term_cache( array( $t1, $t2, $t3 ), $this->taxonomy );
     451
    450452        $set = wp_set_object_terms( $p, array( $t1, $t2, $t3 ), $this->taxonomy );
    451453
Note: See TracChangeset for help on using the changeset viewer.