From d041c830bc0688d5f7cf062e27fb58c439fe78ca Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 5 Sep 2013 17:15:09 +0000 Subject: [PATCH] Avoid database error when `include` or `exclude` is not really a `term_id`. Adds more unit tests. Props kovshenin. Fixes #11823. Built from https://develop.svn.wordpress.org/trunk@25257 git-svn-id: http://core.svn.wordpress.org/trunk@25225 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index c5af198cc7..fa32393b45 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -1310,9 +1310,10 @@ function get_terms($taxonomies, $args = '') { $inclusions = implode( ',', wp_parse_id_list( $include ) ); } - if ( ! empty( $inclusions ) ) + if ( ! empty( $inclusions ) ) { $inclusions = ' AND t.term_id IN ( ' . $inclusions . ' )'; - $where .= $inclusions; + $where .= $inclusions; + } $exclusions = ''; if ( ! empty( $exclude_tree ) ) { @@ -1339,7 +1340,9 @@ function get_terms($taxonomies, $args = '') { $exclusions = ' AND t.term_id NOT IN (' . $exclusions . ')'; $exclusions = apply_filters( 'list_terms_exclusions', $exclusions, $args ); - $where .= $exclusions; + + if ( ! empty( $exclusions ) ) + $where .= $exclusions; if ( !empty($slug) ) { $slug = sanitize_title($slug);