Changeset 9349
- Timestamp:
- 10/25/08 22:56:02 (3 months ago)
- Files:
-
- trunk/wp-includes/post.php (modified) (1 diff)
- trunk/wp-includes/taxonomy.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wp-includes/post.php
r9259 r9349 1594 1594 // Update counts for the post's terms. 1595 1595 foreach ( (array) get_object_taxonomies('post') as $taxonomy ) { 1596 $t erms = wp_get_object_terms($post_id, $taxonomy, 'fields=tt_ids');1597 wp_update_term_count($t erms, $taxonomy);1596 $tt_ids = wp_get_object_terms($post_id, $taxonomy, 'fields=tt_ids'); 1597 wp_update_term_count($tt_ids, $taxonomy); 1598 1598 } 1599 1599 trunk/wp-includes/taxonomy.php
r9229 r9349 971 971 972 972 foreach ( (array) $taxonomies as $taxonomy ) { 973 $t erms = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids');974 $in_t erms = "'" . implode("', '", $terms) . "'";975 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_t erms)", $object_id) );976 wp_update_term_count($t erms, $taxonomy);973 $tt_ids = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids'); 974 $in_tt_ids = "'" . implode("', '", $tt_ids) . "'"; 975 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $object_id) ); 976 wp_update_term_count($tt_ids, $taxonomy); 977 977 } 978 978 } … … 1333 1333 1334 1334 if ( ! $append ) 1335 $old_t erms = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids');1335 $old_tt_ids = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids'); 1336 1336 1337 1337 $tt_ids = array(); … … 1342 1342 continue; 1343 1343 1344 if ( !$ id= is_term($term, $taxonomy) )1345 $ id= wp_insert_term($term, $taxonomy);1346 if ( is_wp_error($ id) )1347 return $ id;1348 $term_ids[] = $ id['term_id'];1349 $ id = $id['term_taxonomy_id'];1350 $tt_ids[] = $ id;1351 1352 if ( $wpdb->get_var( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d", $object_id, $ id ) ) )1344 if ( !$term_info = is_term($term, $taxonomy) ) 1345 $term_info = wp_insert_term($term, $taxonomy); 1346 if ( is_wp_error($term_info) ) 1347 return $term_info; 1348 $term_ids[] = $term_info['term_id']; 1349 $tt_id = $term_info['term_taxonomy_id']; 1350 $tt_ids[] = $tt_id; 1351 1352 if ( $wpdb->get_var( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d", $object_id, $tt_id ) ) ) 1353 1353 continue; 1354 $wpdb->insert( $wpdb->term_relationships, array( 'object_id' => $object_id, 'term_taxonomy_id' => $ id ) );1354 $wpdb->insert( $wpdb->term_relationships, array( 'object_id' => $object_id, 'term_taxonomy_id' => $tt_id ) ); 1355 1355 } 1356 1356 … … 1358 1358 1359 1359 if ( ! $append ) { 1360 $delete_terms = array_diff($old_t erms, $tt_ids);1360 $delete_terms = array_diff($old_tt_ids, $tt_ids); 1361 1361 if ( $delete_terms ) { 1362 1362 $in_delete_terms = "'" . implode("', '", $delete_terms) . "'";
