Changeset 5598 for trunk/wp-includes/taxonomy.php
- Timestamp:
- 05/30/2007 03:36:59 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/taxonomy.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/taxonomy.php
r5597 r5598 429 429 430 430 if ( 'all' == $fields ) 431 $select_this = 't.* ';431 $select_this = 't.*, tt.*'; 432 432 else if ( 'ids' == $fields ) 433 433 $select_this = 't.term_id'; 434 else if ( 'all_with_object_id' == $fields ) 435 $select_this = 't.*, tt.*, tr.object_id'; 434 436 435 437 $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($taxonomies) AND tr.object_id IN ($object_ids) ORDER BY $orderby $order"; 436 438 437 if ( 'all' == $fields ) 438 $taxonomy_data = $wpdb->get_results($query); 439 else if ( 'ids' == $fields ) 440 $taxonomy_data = $wpdb->get_col($query); 441 else if ( 'tt_ids' == $fields ) 442 $taxonomy_data = $wpdb->get_col("SELECT tr.term_taxonomy_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id IN ($object_ids) AND tt.taxonomy IN ($taxonomies) ORDER BY tr.term_taxonomy_id $order"); 443 444 if ( ! $taxonomy_data ) 439 if ( 'all' == $fields || 'all_with_object_id' == $fields ) { 440 $terms = $wpdb->get_results($query); 441 update_term_cache($terms); 442 } else if ( 'ids' == $fields ) { 443 $terms = $wpdb->get_col($query); 444 } else if ( 'tt_ids' == $fields ) { 445 $terms = $wpdb->get_col("SELECT tr.term_taxonomy_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id IN ($object_ids) AND tt.taxonomy IN ($taxonomies) ORDER BY tr.term_taxonomy_id $order"); 446 } 447 448 if ( ! $terms ) 445 449 return array(); 446 450 447 return $t axonomy_data;451 return $terms; 448 452 } 449 453 … … 554 558 $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ($in_taxonomies) $where ORDER BY $orderby $order $number"; 555 559 556 if ( 'all' == $fields ) 560 if ( 'all' == $fields ) { 557 561 $terms = $wpdb->get_results($query); 558 else if ( 'ids' == $fields ) 562 update_term_cache($terms); 563 } else if ( 'ids' == $fields ) { 559 564 $terms = $wpdb->get_col($query); 565 } 560 566 561 567 if ( empty($terms) ) … … 591 597 592 598 $cache[ $key ] = $terms; 593 wp_cache_ add( 'get_terms', $cache, 'term' );599 wp_cache_set( 'get_terms', $cache, 'term' ); 594 600 595 601 $terms = apply_filters('get_terms', $terms, $taxonomies, $args); … … 680 686 } 681 687 688 function update_term_cache($terms, $taxonomy = '') { 689 foreach ( $terms as $term ) { 690 $term_taxonomy = $taxonomy; 691 if ( empty($term_taxonomy) ) 692 $term_taxonomy = $term->taxonomy; 693 694 wp_cache_add($term->term_id, $term, $term_taxonomy); 695 } 696 } 697 682 698 function clean_term_cache($ids, $taxonomy) { 683 699 if ( !is_array($ids) )
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)