[wp-trac] [WordPress Trac] #13060: Duplicate Term bug

WordPress Trac wp-trac at lists.automattic.com
Tue Apr 20 16:55:24 UTC 2010


#13060: Duplicate Term bug
--------------------------+-------------------------------------------------
 Reporter:  DeannaS       |       Owner:  dd32       
     Type:  defect (bug)  |      Status:  assigned   
 Priority:  normal        |   Milestone:  3.0        
Component:  Taxonomy      |     Version:  3.0        
 Severity:  normal        |    Keywords:  needs-patch
--------------------------+-------------------------------------------------
Changes (by nacin):

  * keywords:  reporter-feedback => needs-patch
  * owner:  filosofo => dd32
  * status:  new => assigned


Comment:

 dd32 and I have talked about this bug. Neither of us ended up creating a
 ticket yet (oops) but it's on both of our to-do lists. I'm actually
 surprised it's taken this long for someone else to notice it.

 Steps to reproduce:

 1. Add a category called 'apple'. Don't give it a slug or anything.

 2. Repeat step 1. Should blow up with mysql_real_escape_string() errors.

 How to fix:

 1. Line 1548. $term_id = is_term( $term ) was changed to is_term( $term,
 $tax ) in r13087. When is_term() is given a taxonomy, it decides to return
 an object instead of just a term ID. Easy fix, one of which would be to
 rename $term_id to $_term there and add an else to the end, in which we
 set $term_id = $_term['term_id'].

 2. Once that is fixed, try the steps to reproduce again. You'll end up
 with another row being added to the table to the left, exactly identical.
 The database is untouched. This is because wp_insert_term() returns an
 array (not WP_Error) when the term/slug/taxonomy combo already exists.
 admin-ajax.php doesn't account for that, either as a return value, or
 beforehand. (2.9 used category_exists, i.e. is_term...)

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


More information about the wp-trac mailing list