From 5b5c74b904757afb9fe0a03b0a37d2e8bd127db4 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Wed, 6 Jul 2022 05:09:22 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@53669 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/taxonomy.php | 5 ----- tests/phpunit/tests/taxonomy.php | 3 --- 2 files changed, 8 deletions(-) diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index 15ccacb767..698a0699cc 100644 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -580,11 +580,6 @@ function unregister_taxonomy( $taxonomy ) { $taxonomy_object->remove_rewrite_rules(); $taxonomy_object->remove_hooks(); - // Remove custom taxonomy default term option. - if ( ! empty( $taxonomy_object->default_term ) ) { - delete_option( 'default_term_' . $taxonomy_object->name ); - } - // Remove the taxonomy. unset( $wp_taxonomies[ $taxonomy ] ); diff --git a/tests/phpunit/tests/taxonomy.php b/tests/phpunit/tests/taxonomy.php index 6b7e88007b..69dc1a8180 100644 --- a/tests/phpunit/tests/taxonomy.php +++ b/tests/phpunit/tests/taxonomy.php @@ -1044,9 +1044,6 @@ class Tests_Taxonomy extends WP_UnitTestCase { wp_set_object_terms( $post_id, array(), $tax ); $term = wp_get_post_terms( $post_id, $tax ); $this->assertSame( array(), $term ); - - unregister_taxonomy( $tax ); - $this->assertSame( get_option( 'default_term_' . $tax ), false ); } /**