ensure unique term_id when global terms enabled, see #13482
git-svn-id: https://develop.svn.wordpress.org/trunk@14872 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
aa8a5ab580
commit
7fdb99dbb5
@ -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