Skip to content

Commit 2078d6a

Browse files
authored
Avoid global_terms_enabled() deprecation notice in wp site empty (#669)
1 parent ff72951 commit 2078d6a

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎features/site-empty.feature‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,14 @@ Feature: Empty a WordPress site of its data
128128

129129
When I run `wp --url=example.com/foo post list --format=ids`
130130
Then STDOUT should be empty
131+
132+
@require-wp-6.1
133+
Scenario: Empty a multisite site without deprecation notices
134+
Given a WP multisite installation
135+
And I run `wp config set WP_DEBUG true --raw`
136+
137+
When I run `wp site empty --yes`
138+
Then STDERR should not contain:
139+
"""
140+
global_terms_enabled
141+
"""

‎src/Site_Command.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ private function insert_default_terms() {
118118
/* translators: Default category slug */
119119
$cat_slug = sanitize_title( _x( 'Uncategorized', 'Default category slug' ) );
120120

121+
// global_terms_enabled() is deprecated since WP 6.1, where global terms are always off.
121122
// @phpstan-ignore function.deprecated
122-
if ( global_terms_enabled() ) { // phpcs:ignore WordPress.WP.DeprecatedFunctions.global_terms_enabledFound -- Required for backwards compatibility.
123+
if ( Utils\wp_version_compare( '6.1', '<' ) && global_terms_enabled() ) { // phpcs:ignore WordPress.WP.DeprecatedFunctions.global_terms_enabledFound -- Required for backwards compatibility.
123124
$cat_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
124125
if ( null === $cat_id ) {
125126
$wpdb->insert(

0 commit comments

Comments
 (0)