[wp-trac] [WordPress Trac] #39984: wp_insert_term can return wrong ID when multiple existing terms are found with the same name but differnet parent

WordPress Trac noreply at wordpress.org
Fri Mar 3 02:39:11 UTC 2017


#39984: wp_insert_term can return wrong ID when multiple existing terms are found
with the same name but differnet parent
-------------------------------------------------+-------------------------
 Reporter:  mikejolley                           |       Owner:
     Type:  defect (bug)                         |  boonebgorges
 Priority:  normal                               |      Status:  accepted
Component:  Taxonomy                             |   Milestone:  4.8
 Severity:  normal                               |     Version:  4.2
 Keywords:  has-patch dev-feedback needs-        |  Resolution:
  testing                                        |     Focuses:
-------------------------------------------------+-------------------------

Comment (by boonebgorges):

 In [changeset:"40144"]:
 {{{
 #!CommitTicketReference repository="" revision="40144"
 Taxonomy: Improve precision of duplicate name checks when inserting terms.

 `wp_insert_term()` does not allow for terms with the same name to exist
 at the same hierarchy level, unless the second term has a unique slug.
 When this logic was refactored in [31792] and [34809], a bug was
 introduced whereby it was possible to bypass the no-same-named-sibling
 check in cases where the first term had a non-auto-generated slug
 (ie, where the name was 'Foo' but the slug something other than 'foo',
 such that the second term would get the non-matching slug 'foo').

 This changeset fixes this issue by ensuring that the duplicate name
 check runs both in cases where there's an actual slug clash *and* in
 cases where no explicit `slug` has been provided to `wp_insert_term()`.
 The result is a more reliable error condition:
 `wp_insert_term( 'Foo' ... )` will always fail if there's a sibling
 'Foo', regardless of the sibling's slug.

 Props mikejolley.
 See #39984.
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39984#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list