[wp-trac] [WordPress Trac] #21639: wp_update_term doesn't honor taxonomy

WordPress Trac wp-trac at lists.automattic.com
Mon Aug 20 15:47:41 UTC 2012


#21639: wp_update_term doesn't honor taxonomy
--------------------------+-----------------------------
 Reporter:  Whissi        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:  3.4.1
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 Hi,

 I wanted to programmatically change my categories. This is the code I
 would use:
 {{{
 #!php
 [...]
 foreach ( $categories_to_rename AS $category ) {
         $cat_ID = (int) $category->cat_ID;
         if ( $cat_ID === 1 ) {
                 // Skip default category
                 continue;
         }

         $updatedCategory = array();
         $updatedCategory['slug'] = getTheNewCategoryNameFromSomewhere(
 $cat_ID );

         $update_response = wp_update_term( $cat_ID, 'category',
 $updatedCategory )

         if ( is_wp_error( $update_response ) )
                 return $update_response;
 }
 [...]
 }}}
 After that I noticed, that the slug of some tags were changed, too.

 I looked into the database and noticed, that some tags shared the same
 term with a category. Because I updated the slug, which is stored in the
 terms table, the tag name was "updated", too.

 This is something I don't expect. When I call an update on "category", I
 don't expect that something else will update, too.

 When it is allowed, that a category and a tag will share the same term,
 this sharing should end when you update just one part.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21639>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list