[wp-trac] [WordPress Trac] #36387: Function: term_exists() fails on children with ampersand

WordPress Trac noreply at wordpress.org
Thu Mar 31 16:17:48 UTC 2016


#36387: Function: term_exists() fails on children with ampersand
-------------------------------------------------+-------------------------
 Reporter:  Howdy_McGee                          |      Owner:
     Type:  defect (bug)                         |     Status:  new
 Priority:  normal                               |  Milestone:  Awaiting
Component:  Taxonomy                             |  Review
 Severity:  normal                               |    Version:  4.4.2
  Focuses:  administration, template,            |   Keywords:
  performance                                    |
-------------------------------------------------+-------------------------
 This may be a very specific case but it's 100% replicable. Post Categories
 should look like this:

 Foo & Bar ( Slug: foo-bar )
     - Foo & Bar ( Slug: foo-bar-foo-bar )

 Parent and child have the same name with an ampersand. Then you check if
 each term exists in their respective parents:

 {{{#!php
 term_exists( 'Foo & Bar', 'category', 0 );
 }}}

 Returns expected results of the Term Array. The issue comes when you pass
 the parents ID:

 {{{#!php
 term_exists( 'Foo & Bar', 'category', $parent_id );
 }}}

 Returns `NULL` which is an issue as if you're trying to insert a term if
 it doesn't exists using `wp_insert_term()` you get a WP Error:

 > A term with the name provided already exists with this parent.

 If I change the above ampersands to 'and' I don't run into this issue.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36387>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list