[wp-trac] [WordPress Trac] #11003: wp_get_object_terms Returns Duplicate Terms

WordPress Trac wp-trac at lists.automattic.com
Wed Dec 23 05:19:53 UTC 2009


#11003: wp_get_object_terms Returns Duplicate Terms
--------------------------+-------------------------------------------------
 Reporter:  filosofo      |       Owner:  ryan     
     Type:  defect (bug)  |      Status:  new      
 Priority:  normal        |   Milestone:  3.0      
Component:  Taxonomy      |     Version:  2.9      
 Severity:  normal        |    Keywords:  has-patch
--------------------------+-------------------------------------------------

Comment(by dd32):

 Before:
 {{{
 $terms = wp_get_object_terms( array(10,12), 'category', array('fields' =>
 'all_with_object_id') );

 var_dump($terms);

 array(2) {
   [0]=>
   object(stdClass)#10 (10) {
     ["term_id"]=>
     string(1) "4"
     ["name"]=>
     string(6) "Artist"
     ["slug"]=>
     string(6) "artist"
     ["term_group"]=>
     string(1) "0"
     ["term_taxonomy_id"]=>
     string(1) "4"
     ["taxonomy"]=>
     string(8) "category"
     ["description"]=>
     string(0) ""
     ["parent"]=>
     string(1) "0"
     ["count"]=>
     string(1) "2"
     ["object_id"]=>
     string(2) "10"
   }
   [1]=>
   object(stdClass)#9 (10) {
     ["term_id"]=>
     string(1) "4"
     ["name"]=>
     string(6) "Artist"
     ["slug"]=>
     string(6) "artist"
     ["term_group"]=>
     string(1) "0"
     ["term_taxonomy_id"]=>
     string(1) "4"
     ["taxonomy"]=>
     string(8) "category"
     ["description"]=>
     string(0) ""
     ["parent"]=>
     string(1) "0"
     ["count"]=>
     string(1) "2"
     ["object_id"]=>
     string(2) "12"
   }
 }
 }}}

 Note, Object ID in there.

 With wp_get_object_terms-unique-results.11003.diff:
 {{{
 $terms = wp_get_object_terms( array(10,12), 'category', array('fields' =>
 'all_with_object_id') );

 var_dump($terms);

 array(1) {
   [4]=>
   object(stdClass)#9 (10) {
     ["term_id"]=>
     string(1) "4"
     ["name"]=>
     string(6) "Artist"
     ["slug"]=>
     string(6) "artist"
     ["term_group"]=>
     string(1) "0"
     ["term_taxonomy_id"]=>
     string(1) "4"
     ["taxonomy"]=>
     string(8) "category"
     ["description"]=>
     string(0) ""
     ["parent"]=>
     string(1) "0"
     ["count"]=>
     string(1) "2"
     ["object_id"]=>
     string(2) "12"
   }
 }
 }}}

 Note, that due to the indexing of the array on $term->term_id in order to
 filter out duplicates, the 2 have been combined.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/11003#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list