Skip to content

Commit 7a6ba32

Browse files
committed
Networks and Sites: Officially remove global terms.
Global terms was a feature from the WordPress MU days where multisite and single site installs used different code bases. In WordPress 3.0, WordPress MU was merged into one location and the UI [14854] and “on” switch [14880] for global terms were completely removed. Even before this merge, global terms was bug infested and unreliable. After [14854]/[14880], the feature was no longer maintained and became increasingly broken as taxonomies progressed without it (term splitting and term meta do not work at all). At this point, the feature has not worked in 12+ years and there’s no hope for saving it. This deprecates the remaining global terms related code and no-ops the functions. Global terms, you don’t have to go home, but you can’t stay here. Props scribu, wonderboymusic, SergeyBiryukov, nacin, pento, desrosj, johnjamesjacoby, johnbillion, dd32. Fixes #21734. git-svn-id: https://develop.svn.wordpress.org/trunk@54240 602fd350-edb4-49c9-b593-d223f7449a82
1 parent f2f99f3 commit 7a6ba32

15 files changed

+82
-216
lines changed

src/wp-admin/edit-tag-form.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@
148148
<td><input name="name" id="name" type="text" value="<?php echo $tag_name_value; ?>" size="40" aria-required="true" aria-describedby="name-description" />
149149
<p class="description" id="name-description"><?php echo $tax->labels->name_field_description; ?></p></td>
150150
</tr>
151-
<?php if ( ! global_terms_enabled() ) { ?>
152151
<tr class="form-field term-slug-wrap">
153152
<th scope="row"><label for="slug"><?php _e( 'Slug' ); ?></label></th>
154153
<?php
@@ -170,7 +169,6 @@
170169
<td><input name="slug" id="slug" type="text" value="<?php echo esc_attr( $slug ); ?>" size="40" aria-describedby="slug-description" />
171170
<p class="description" id="slug-description"><?php echo $tax->labels->slug_field_description; ?></p></td>
172171
</tr>
173-
<?php } ?>
174172
<?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?>
175173
<tr class="form-field term-parent-wrap">
176174
<th scope="row"><label for="parent"><?php echo esc_html( $tax->labels->parent_item ); ?></label></th>

src/wp-admin/edit-tags.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,7 @@
280280
$help .= '<ul>' .
281281
'<li>' . __( '<strong>Name</strong> &mdash; The name is how it appears on your site.' ) . '</li>';
282282

283-
if ( ! global_terms_enabled() ) {
284-
$help .= '<li>' . __( '<strong>Slug</strong> &mdash; The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ) . '</li>';
285-
}
283+
$help .= '<li>' . __( '<strong>Slug</strong> &mdash; The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ) . '</li>';
286284

287285
if ( 'category' === $taxonomy ) {
288286
$help .= '<li>' . __( '<strong>Parent</strong> &mdash; Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have child categories for Bebop and Big Band. Totally optional. To create a subcategory, just choose another category from the Parent dropdown.' ) . '</li>';
@@ -456,13 +454,11 @@
456454
<input name="tag-name" id="tag-name" type="text" value="" size="40" aria-required="true" aria-describedby="name-description" />
457455
<p id="name-description"><?php echo $tax->labels->name_field_description; ?></p>
458456
</div>
459-
<?php if ( ! global_terms_enabled() ) : ?>
460457
<div class="form-field term-slug-wrap">
461458
<label for="tag-slug"><?php _e( 'Slug' ); ?></label>
462459
<input name="slug" id="tag-slug" type="text" value="" size="40" aria-describedby="slug-description" />
463460
<p id="slug-description"><?php echo $tax->labels->slug_field_description; ?></p>
464461
</div>
465-
<?php endif; // global_terms_enabled() ?>
466462
<?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?>
467463
<div class="form-field term-parent-wrap">
468464
<label for="parent"><?php echo esc_html( $tax->labels->parent_item ); ?></label>

src/wp-admin/includes/class-wp-terms-list-table.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -665,12 +665,10 @@ public function inline_edit() {
665665
<span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>
666666
</label>
667667

668-
<?php if ( ! global_terms_enabled() ) : ?>
669-
<label>
670-
<span class="title"><?php _e( 'Slug' ); ?></span>
671-
<span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
672-
</label>
673-
<?php endif; ?>
668+
<label>
669+
<span class="title"><?php _e( 'Slug' ); ?></span>
670+
<span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
671+
</label>
674672
</div>
675673
</fieldset>
676674

src/wp-admin/includes/ms-admin-filters.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
// Network hooks.
2323
add_action( 'update_site_option_admin_email', 'wp_network_admin_email_change_notification', 10, 4 );
2424

25-
// Taxonomy hooks.
26-
add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 );
27-
2825
// Post hooks.
2926
add_filter( 'wp_insert_post_data', 'avoid_blog_page_permalink_collision', 10, 2 );
3027

src/wp-admin/includes/ms-deprecated.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,33 @@ function wpmu_get_blog_allowedthemes( $blog_id = 0 ) {
108108
* @deprecated 3.5.0
109109
*/
110110
function ms_deprecated_blogs_file() {}
111+
112+
if ( ! function_exists( 'install_global_terms' ) ) :
113+
/**
114+
* Install global terms.
115+
*
116+
* @since 3.0.0
117+
* @since 6.1.0 This function no longer does anything.
118+
* @deprecated 6.1.0
119+
*/
120+
function install_global_terms() {
121+
_deprecated_function( __FUNCTION__, '6.1.0' );
122+
}
123+
endif;
124+
125+
/**
126+
* Synchronizes category and post tag slugs when global terms are enabled.
127+
*
128+
* @since 3.0.0
129+
* @since 6.1.0 This function no longer does anything.
130+
* @deprecated 6.1.0
131+
*
132+
* @param WP_Term|array $term The term.
133+
* @param string $taxonomy The taxonomy for `$term`.
134+
* @return WP_Term|array Always returns `$term`.
135+
*/
136+
function sync_category_tag_slugs( $term, $taxonomy ) {
137+
_deprecated_function( __FUNCTION__, '6.1.0' );
138+
139+
return $term;
140+
}

src/wp-admin/includes/ms.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -543,29 +543,6 @@ function format_code_lang( $code = '' ) {
543543
return strtr( $code, $lang_codes );
544544
}
545545

546-
/**
547-
* Synchronizes category and post tag slugs when global terms are enabled.
548-
*
549-
* @since 3.0.0
550-
*
551-
* @param WP_Term|array $term The term.
552-
* @param string $taxonomy The taxonomy for `$term`. Should be 'category' or 'post_tag', as these are
553-
* the only taxonomies which are processed by this function; anything else
554-
* will be returned untouched.
555-
* @return WP_Term|array Returns `$term`, after filtering the 'slug' field with `sanitize_title()`
556-
* if `$taxonomy` is 'category' or 'post_tag'.
557-
*/
558-
function sync_category_tag_slugs( $term, $taxonomy ) {
559-
if ( global_terms_enabled() && ( 'category' === $taxonomy || 'post_tag' === $taxonomy ) ) {
560-
if ( is_object( $term ) ) {
561-
$term->slug = sanitize_title( $term->name );
562-
} else {
563-
$term['slug'] = sanitize_title( $term['name'] );
564-
}
565-
}
566-
return $term;
567-
}
568-
569546
/**
570547
* Displays an access denied message when a user tries to view a site's dashboard they
571548
* do not have access to.

src/wp-admin/includes/schema.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,6 @@ function populate_network_meta( $network_id, array $meta = array() ) {
12701270
'add_new_users' => '0',
12711271
'upload_space_check_disabled' => is_multisite() ? get_site_option( 'upload_space_check_disabled' ) : '1',
12721272
'subdomain_install' => $subdomain_install,
1273-
'global_terms_enabled' => global_terms_enabled() ? '1' : '0',
12741273
'ms_files_rewriting' => is_multisite() ? get_site_option( 'ms_files_rewriting' ) : '0',
12751274
'user_count' => get_site_option( 'user_count' ),
12761275
'initial_db_version' => get_option( 'initial_db_version' ),

src/wp-admin/includes/upgrade.php

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -159,24 +159,7 @@ function wp_install_defaults( $user_id ) {
159159
/* translators: Default category slug. */
160160
$cat_slug = sanitize_title( _x( 'Uncategorized', 'Default category slug' ) );
161161

162-
if ( global_terms_enabled() ) {
163-
$cat_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
164-
if ( null == $cat_id ) {
165-
$wpdb->insert(
166-
$wpdb->sitecategories,
167-
array(
168-
'cat_ID' => 0,
169-
'cat_name' => $cat_name,
170-
'category_nicename' => $cat_slug,
171-
'last_updated' => current_time( 'mysql', true ),
172-
)
173-
);
174-
$cat_id = $wpdb->insert_id;
175-
}
176-
update_option( 'default_category', $cat_id );
177-
} else {
178-
$cat_id = 1;
179-
}
162+
$cat_id = 1;
180163

181164
$wpdb->insert(
182165
$wpdb->terms,
@@ -3537,33 +3520,6 @@ function pre_schema_upgrade() {
35373520
}
35383521
}
35393522

3540-
if ( ! function_exists( 'install_global_terms' ) ) :
3541-
/**
3542-
* Install global terms.
3543-
*
3544-
* @since 3.0.0
3545-
*
3546-
* @global wpdb $wpdb WordPress database abstraction object.
3547-
* @global string $charset_collate
3548-
*/
3549-
function install_global_terms() {
3550-
global $wpdb, $charset_collate;
3551-
$ms_queries = "
3552-
CREATE TABLE $wpdb->sitecategories (
3553-
cat_ID bigint(20) NOT NULL auto_increment,
3554-
cat_name varchar(55) NOT NULL default '',
3555-
category_nicename varchar(200) NOT NULL default '',
3556-
last_updated timestamp NOT NULL,
3557-
PRIMARY KEY (cat_ID),
3558-
KEY category_nicename (category_nicename),
3559-
KEY last_updated (last_updated)
3560-
) $charset_collate;
3561-
";
3562-
// Now create tables.
3563-
dbDelta( $ms_queries );
3564-
}
3565-
endif;
3566-
35673523
/**
35683524
* Determine if global tables should be upgraded.
35693525
*

src/wp-admin/network/settings.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
'welcome_email',
101101
'welcome_user_email',
102102
'fileupload_maxk',
103-
'global_terms_enabled',
104103
'illegal_names',
105104
'limited_email_domains',
106105
'banned_email_domains',

src/wp-includes/class-wpdb.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,19 @@ class wpdb {
340340
'signups',
341341
'site',
342342
'sitemeta',
343-
'sitecategories',
344343
'registration_log',
345344
);
346345

346+
/**
347+
* List of deprecated WordPress Multisite global tables.
348+
*
349+
* @since 6.1.0
350+
*
351+
* @see wpdb::tables()
352+
* @var string[]
353+
*/
354+
public $old_ms_global_tables = array( 'sitecategories' );
355+
347356
/**
348357
* WordPress Comments table.
349358
*
@@ -1123,11 +1132,13 @@ public function get_blog_prefix( $blog_id = null ) {
11231132
* - 'old' - returns tables which are deprecated.
11241133
*
11251134
* @since 3.0.0
1135+
* @since 6.1.0 `old` now includes deprecated multisite global tables only on multisite.
11261136
*
11271137
* @uses wpdb::$tables
11281138
* @uses wpdb::$old_tables
11291139
* @uses wpdb::$global_tables
11301140
* @uses wpdb::$ms_global_tables
1141+
* @uses wpdb::$old_ms_global_tables
11311142
*
11321143
* @param string $scope Optional. Possible values include 'all', 'global', 'ms_global', 'blog',
11331144
* or 'old' tables. Default 'all'.
@@ -1159,6 +1170,9 @@ public function tables( $scope = 'all', $prefix = true, $blog_id = 0 ) {
11591170
break;
11601171
case 'old':
11611172
$tables = $this->old_tables;
1173+
if ( is_multisite() ) {
1174+
$tables = array_merge( $tables, $this->old_ms_global_tables );
1175+
}
11621176
break;
11631177
default:
11641178
return array();

0 commit comments

Comments
 (0)