[wp-trac] [WordPress Trac] #20850: Duplicate term insertion allowed after insertion with case differences

WordPress Trac wp-trac at lists.automattic.com
Wed Jun 6 00:00:34 UTC 2012


#20850: Duplicate term insertion allowed after insertion with case differences
--------------------------+-----------------------------
 Reporter:  jazbek        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:  3.3.2
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 I've discovered a case where duplicate terms can be inserted with
 wp_insert_term(). Steps to reproduce:

 1. Insert a term, i.e.
 {{{
  wp_insert_term('USA', 'country');
 }}}
 2. Insert the same term, but with a different case, i.e.
 {{{
  wp_insert_term('usa', 'country'); // it's ok that this succeeds, because
 technically it *is* different (case-wise)
 }}}
 3. Insert the same term as in step 2. It should fail, but doesn't:
 {{{
  wp_insert_term('usa', 'country'); // succeeds
 }}}

 This is because wp_insert_term() does the following:
 1. Finds the first term in the db that matches the initial (non-unique)
 slug for the new term name
 2. If the name of the found term doesn't match the new term name, then
 insert continues. In the example above, it's comparing all subsequent
 'usa' term names to the first 'USA' term name and determining that it's ok
 to continue, when it's not because there are other 'usa' terms that it
 didn't look at.

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


More information about the wp-trac mailing list