#54472 closed defect (bug) (fixed)
Taxonomy: Unregistering taxonomy with default term endlessly regenerates options
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | 5.5 |
Component: | Taxonomy | Keywords: | has-patch commit needs-dev-note |
Focuses: | performance | Cc: |
Description
[48480] added logic to unregister_taxonomy()
to delete the default term option for the taxonomy if it had a default term. This logic causes the default term option for the taxonomy to be created and then deleted on every request: created when the taxonomy is registered, deleted when the taxonomy is unregistered, created again in the next request because it was deleted in the previous request, and so on.
Since taxonomies are registered at runtime and can't be unregistered unless they're already registered, the option will necessarily be created and deleted within the same request and again on every subsequent request, as opposed to a one-time operation like plugin deactivation.
I can sympathize with the desire to "clean up" the database as part of unregistering the taxonomy, but the cost to performance seems unnecessarily high in this case. There's also precedent: the {$taxonomy}_children
option isn't deleted when the taxonomy is unregistered, either.
Accordingly, the linked Pull Request would remove the delete_option()
call from unregister_taxonomy()
.
Change History (10)
This ticket was mentioned in PR #1916 on WordPress/wordpress-develop by dlh01.
3 years ago
#1
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
3 years ago
#4
@
3 years ago
- Milestone changed from 5.9 to 6.0
Moving this ticket to 6.0 as we're releasing WP 5.9 beta 1.
This ticket was mentioned in Slack in #core by costdev. View the logs.
3 years ago
#7
@
3 years ago
- Milestone changed from 6.0 to 6.1
With 6.0 RC1 starting soon, I'm moving this to the 6.1 milestone.
#8
@
3 years ago
- Keywords commit needs-dev-note added; needs-testing removed
I've tested this with a mini plugin that registers and then unregisters a taxonomy with a default term.
Trunk
Each and every page load includes the following database queries:
INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES ('default_term_pwcc_test_taxonomy', '19', 'yes') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`); DELETE FROM `wp_options` WHERE `option_name` = 'default_term_pwcc_test_taxonomy';
With the patch applied
The FIRST request adds the default option to the database as the taxonomy is registered:
INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES ('default_term_pwcc_test_taxonomy', '19', 'yes') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`);
The SECOND and subsequent requests make no changes to the database.
#9
@
3 years ago
- Owner set to peterwilsoncc
- Resolution set to fixed
- Status changed from new to closed
In 53669:
peterwilsoncc commented on PR #1916:
3 years ago
#10
Committed in 5b5c74b904757afb9fe0a03b0a37d2e8bd127db4 (canonically https://core.trac.wordpress.org/changeset/53669)
Trac ticket: https://core.trac.wordpress.org/ticket/54472