[wp-trac] [WordPress Trac] #64090: Unexpected DB query when inserting a non-hierarchical term

WordPress Trac noreply at wordpress.org
Fri Oct 10 13:33:42 UTC 2025


#64090: Unexpected DB query when inserting a non-hierarchical term
--------------------------+-----------------------------
 Reporter:  Chouby        |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:
 Severity:  normal        |   Keywords:
  Focuses:  performance   |
--------------------------+-----------------------------
 When inserting a new non-hierarchical term, an unexpected query (valid for
 hierarchical terms) is uselessly made. Example for post tags:
 {{{
 SELECT autoload FROM wptests_options WHERE option_name =
 'post_tag_children'
 }}}

 This test allows to easily reproduce the issue.
 {{{#!php
 <?php
         public function test_unexpected_query_wp_insert_term() {
                 global $wpdb;

                 define( 'SAVEQUERIES', true );

                 wp_insert_term( 'test', 'post_tag' );

                 $queries = array_column( $wpdb->queries, 0 );
                 $search  = array_search( "SELECT autoload FROM
 wptests_options WHERE option_name = 'post_tag_children'", $queries );
                 $this->assertFalse( $search );
         }
 }}}

 This useless query comes from the `clean_taxonomy_cache()` which always
 calls `delete_option( "{$taxonomy}_children" );` regardless of the
 existence of this option.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/64090>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list