mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-10 18:37:58 +01:00
ensure unique term_id when global terms enabled, see #13482
git-svn-id: http://svn.automattic.com/wordpress/trunk@14872 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6eb9b64e22
commit
d8fe68385d
@ -1235,8 +1235,9 @@ function global_terms( $term_id, $deprecated = '' ) {
|
||||
$global_id = $wpdb->insert_id;
|
||||
} else {
|
||||
$max_global_id = $wpdb->get_var( "SELECT MAX(cat_ID) FROM $wpdb->sitecategories" );
|
||||
$max_global_id += mt_rand( 100, 400 );
|
||||
$wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $global_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) );
|
||||
$max_local_id = $wpdb->get_var( "SELECT MAX(term_id) FROM $wpdb->terms" );
|
||||
$new_global_id = max( $max_global_id, $max_local_id ) + mt_rand( 100, 400 );
|
||||
$wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $new_global_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) );
|
||||
$global_id = $wpdb->insert_id;
|
||||
}
|
||||
} elseif ( $global_id != $term_id ) {
|
||||
|
Loading…
Reference in New Issue
Block a user