Make WordPress Core

Changeset 53669


Ignore:
Timestamp:
07/06/2022 05:09:22 AM (2 years ago)
Author:
peterwilsoncc
Message:

Taxonomy: Retain default term option when unregistering taxos.

No longer delete the default term option in unregister_taxonomy() to improve database performance.

Since taxonomies are registered at runtime and can't be unregistered unless they're already registered, prior to this
change the option was created and deleted on each request.

Deleting the option should occur on a one-time opperation such as plugin deactivation.

Follow up to [48480].

Props dlh.
Fixes #54472.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy.php

    r53627 r53669  
    580580    $taxonomy_object->remove_rewrite_rules();
    581581    $taxonomy_object->remove_hooks();
    582 
    583     // Remove custom taxonomy default term option.
    584     if ( ! empty( $taxonomy_object->default_term ) ) {
    585         delete_option( 'default_term_' . $taxonomy_object->name );
    586     }
    587582
    588583    // Remove the taxonomy.
  • trunk/tests/phpunit/tests/taxonomy.php

    r53371 r53669  
    10451045        $term = wp_get_post_terms( $post_id, $tax );
    10461046        $this->assertSame( array(), $term );
    1047 
    1048         unregister_taxonomy( $tax );
    1049         $this->assertSame( get_option( 'default_term_' . $tax ), false );
    10501047    }
    10511048
Note: See TracChangeset for help on using the changeset viewer.