Make WordPress Core

Ticket #11003: wp_get_object_terms-unique-results.11003.diff

File wp_get_object_terms-unique-results.11003.diff, 859 bytes (added by filosofo, 15 years ago)
  • wp-includes/taxonomy.php

     
    12911291                $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) $orderby $order");
    12921292        }
    12931293
    1294         if ( ! $terms )
    1295                 $terms = array();
     1294        if ( in_array($fields, array('ids', 'names', 'tt_ids') ) ) {
     1295                $terms = array_unique((array) $terms);
     1296        } else {
     1297                $_terms = array();
     1298                foreach( (array) $terms as $term ) {
     1299                        $_terms[$term->term_id] = $term;
     1300                }
     1301                $terms = $_terms;
     1302        }
    12961303
    12971304        return apply_filters('wp_get_object_terms', $terms, $object_ids, $taxonomies, $args);
    12981305}