[wp-trac] [WordPress Trac] #35321: Inserting a term with a description of null results in the term being created, but not its relationship to a taxonomy

WordPress Trac noreply at wordpress.org
Tue Jan 5 21:33:39 UTC 2016


#35321: Inserting a term with a description of null results in the term being
created, but not its relationship to a taxonomy
--------------------------+-----------------------------
 Reporter:  eclev91       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  4.4
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Given the following:
 {{{#!php
 <?php
 $t = wp_insert_term(
       'Foo',
       'bar',
       array(
           "description"=> null
       )
   );
 }}}


 And given that `bar` is a registered taxonomy:

 With debug on, you get:


 {{{
 WordPress database error: [Column 'description' cannot be null]
 INSERT INTO `wp_term_taxonomy` (`term_id`, `taxonomy`, `description`,
 `parent`, `count`) VALUES (119, 'bar', NULL, 0, 0)
 }}}


 And otherwise it fails silently.

 The problem: The term is still created! If you dump `$t` you'll see:


 {{{
 Array
 (
     [term_id] => 119
     [term_taxonomy_id] => 0
 )
 }}}


 Expected behavior: Return a WP_Error on the SQL failure rather than create
 a term without a taxonomy.

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


More information about the wp-trac mailing list