Changeset 13925 for trunk/wp-includes/ms-functions.php
- Timestamp:
- 04/02/2010 01:26:44 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/ms-functions.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/ms-functions.php
r13884 r13925 1206 1206 */ 1207 1207 function global_terms( $term_id, $deprecated = '' ) { 1208 global $wpdb ;1208 global $wpdb, $global_terms_recurse; 1209 1209 1210 1210 if ( !global_terms_enabled() ) 1211 1211 return $term_id; 1212 1212 1213 // prevent a race condition 1214 if ( !isset( $global_terms_recurse ) ) { 1215 $recurse_start = true; 1216 $global_terms_recurse = 1; 1217 } elseif ( 10 < $global_terms_recurse++ ) { 1218 return $term_id; 1219 $recurse_start = false; 1220 } 1221 1213 1222 $term_id = intval( $term_id ); 1214 1223 $c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms WHERE term_id = %d", $term_id ) ); … … 1216 1225 $global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE category_nicename = %s", $c->slug ) ); 1217 1226 if ( $global_id == null ) { 1218 $wpdb->insert( $wpdb->sitecategories, array('cat_name' => $c->name, 'category_nicename' => $c->slug) ); 1219 $global_id = $wpdb->insert_id; 1220 } 1221 1222 if ( $global_id == $term_id ) 1223 return $global_id; 1224 1225 if ( get_option( 'default_category' ) == $term_id ) 1226 update_option( 'default_category', $global_id ); 1227 1228 $wpdb->update( $wpdb->terms, array('term_id' => $global_id), array('term_id' => $term_id) ); 1229 $wpdb->update( $wpdb->term_taxonomy, array('term_id' => $global_id), array('term_id' => $term_id) ); 1230 $wpdb->update( $wpdb->term_taxonomy, array('parent' => $global_id), array('parent' => $term_id) ); 1231 1232 clean_term_cache($term_id); 1227 $used_global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE cat_ID = %d", $c->term_id ) ); 1228 if ( null == $used_global_id ) { 1229 $wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $term_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) ); 1230 $global_id = $wpdb->insert_id; 1231 } else { 1232 $max_global_id = $wpdb->get_var( "SELECT MAX(cat_ID) FROM $wpdb->sitecategories" ); 1233 $max_global_id += mt_rand( 100, 400 ); 1234 $wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $global_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) ); 1235 $global_id = $wpdb->insert_id; 1236 } 1237 } elseif ( $global_id != $term_id ) { 1238 $local_id = $wpdb->get_row( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE term_id = %d", $global_id ) ); 1239 if ( null != $local_id ) 1240 $local_id = global_terms( $local_id ); 1241 if ( 10 < $global_terms_recurse ) 1242 $global_id = $term_id; 1243 } 1244 1245 if ( $global_id != $term_id ) { 1246 if ( get_option( 'default_category' ) == $term_id ) 1247 update_option( 'default_category', $global_id ); 1248 1249 $wpdb->update( $wpdb->terms, array('term_id' => $global_id), array('term_id' => $term_id) ); 1250 $wpdb->update( $wpdb->term_taxonomy, array('term_id' => $global_id), array('term_id' => $term_id) ); 1251 $wpdb->update( $wpdb->term_taxonomy, array('parent' => $global_id), array('parent' => $term_id) ); 1252 1253 clean_term_cache($term_id); 1254 } 1255 if( $recurse_start ) 1256 unset( $global_terms_recurse ); 1233 1257 1234 1258 return $global_id;
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)