[wp-trac] [WordPress Trac] #41867: wp_list_categories throws SQL error if list is empty

WordPress Trac noreply at wordpress.org
Wed Sep 13 12:57:04 UTC 2017


#41867: wp_list_categories throws SQL error if list is empty
-------------------------------+------------------------------
 Reporter:  firebird75         |       Owner:
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Taxonomy           |     Version:  4.8.1
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------
Changes (by subrataemfluence):

 * keywords:   => reporter-feedback


Comment:

 I created a custom post type (movie) and custom taxonomy (genre,
 associated with movie). The taxonomy has only one term "Comedy" and it has
 no parent.

 I also have a post under movie which where I have associated the only
 taxonomy term.

 Here is my code:

 {{{#!php
 <?php
 $args = array('taxonomy' => 'movies_taxonomy',
     'depth' => 1,
     'exclude' => 16,
     'echo' => 0,
     'hierarchical' => true,
     'hide_empty' => false,
     'show_count' => 1,
     'title_li' => '');

 echo wp_list_categories($args);
 global $wpdb;
 echo $wpdb->last_query;
 }}}


 As expected `wp_list_categories($args)` does not come up with any taxonomy
 item since I have only one (ID = 16) and that has been excluded in the
 query.

 And here is the output of `$wpdb->last_query`:

 {{{
 SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON
 t.term_id = tt.term_id WHERE tt.taxonomy IN ('genre') AND t.term_id NOT IN
 (16) ORDER BY t.name ASC, which is different from yours.
 }}}


 Can you please tell me the steps to reproduce?

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


More information about the wp-trac mailing list