Ticket #11823: 11823.4.diff
File 11823.4.diff, 2.0 KB (added by , 11 years ago) |
---|
-
src/wp-includes/taxonomy.php
1310 1310 $inclusions = implode( ',', wp_parse_id_list( $include ) ); 1311 1311 } 1312 1312 1313 if ( ! empty( $inclusions ) ) 1313 if ( ! empty( $inclusions ) ) { 1314 1314 $inclusions = ' AND t.term_id IN ( ' . $inclusions . ' )'; 1315 $where .= $inclusions; 1315 $where .= $inclusions; 1316 } 1316 1317 1317 1318 $exclusions = ''; 1318 1319 if ( ! empty( $exclude_tree ) ) { … … 1339 1340 $exclusions = ' AND t.term_id NOT IN (' . $exclusions . ')'; 1340 1341 1341 1342 $exclusions = apply_filters( 'list_terms_exclusions', $exclusions, $args ); 1342 $where .= $exclusions;1343 1343 1344 if ( ! empty( $exclusions ) ) 1345 $where .= $exclusions; 1346 1344 1347 if ( !empty($slug) ) { 1345 1348 $slug = sanitize_title($slug); 1346 1349 $where .= " AND t.slug = '$slug'"; -
tests/phpunit/tests/term/getTerms.php
121 121 } 122 122 123 123 /** 124 * @ti 125 * cket 11823 124 * @ticket 11823 126 125 */ 127 126 function test_get_terms_include_exclude() { 127 global $wpdb; 128 128 129 $term_id1 = $this->factory->tag->create(); 129 130 $term_id2 = $this->factory->tag->create(); 130 131 $inc_terms = get_terms( 'post_tag', array( … … 138 139 'hide_empty' => false 139 140 ) ); 140 141 $this->assertEquals( array(), wp_list_pluck( $exc_terms, 'term_id' ) ); 142 143 // These should not generate query errors. 144 get_terms( 'post_tag', array( 'exclude' => array( 0 ), 'hide_empty' => false ) ); 145 $this->assertEmpty( $wpdb->last_error ); 146 147 get_terms( 'post_tag', array( 'exclude' => array( 'unexpected-string' ), 'hide_empty' => false ) ); 148 $this->assertEmpty( $wpdb->last_error ); 149 150 get_terms( 'post_tag', array( 'include' => array( 'unexpected-string' ), 'hide_empty' => false ) ); 151 $this->assertEmpty( $wpdb->last_error ); 141 152 } 142 153 143 154 /**