Ticket #21949: 21949.2.diff
File 21949.2.diff, 2.5 KB (added by , 9 years ago) |
---|
-
src/wp-includes/class-wp.php
diff --git src/wp-includes/class-wp.php src/wp-includes/class-wp.php index 50d3638..539bfdd 100644
class WP { 298 298 if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) ) 299 299 $this->query_vars[$t->query_var] = str_replace( ' ', '+', $this->query_vars[$t->query_var] ); 300 300 301 // Don't allow non-public taxonomies to be queried. 302 foreach ( get_taxonomies( array( 'public' => false ), 'objects' ) as $taxonomy => $t ) { 303 // Check first for taxonomy-specific query_var. 304 if ( $t->query_var && isset( $this->query_vars[ $t->query_var ] ) ) { 305 unset( $this->query_vars[ $t->query_var ] ); 306 } 307 308 // Next, check the 'taxonomy' query_var. 309 if ( isset( $this->query_vars['taxonomy'] ) && $taxonomy === $this->query_vars['taxonomy'] ) { 310 unset( $this->query_vars['taxonomy'], $this->query_vars['term'] ); 311 } 312 } 313 301 314 // Limit publicly queried post_types to those that are publicly_queryable 302 315 if ( isset( $this->query_vars['post_type']) ) { 303 316 $queryable_post_types = get_post_types( array('publicly_queryable' => true) ); -
tests/phpunit/tests/taxonomy.php
diff --git tests/phpunit/tests/taxonomy.php tests/phpunit/tests/taxonomy.php index 8db5bfe..5a6af2e 100644
class Tests_Taxonomy extends WP_UnitTestCase { 442 442 $this->assertEqualSets( array( $t1 ), get_ancestors( $t2, 'wptests_conflict' ) ); 443 443 _unregister_post_type( 'wptests_pt' ); 444 444 } 445 446 /** 447 * @ticket 21949 448 */ 449 public function test_nonpublic_taxonomy_should_not_be_queryable_using_taxname_query_var() { 450 register_taxonomy( 'wptests_tax', 'post', array( 451 'public' => false, 452 ) ); 453 454 $t = $this->factory->term->create_and_get( array( 455 'taxonomy' => 'wptests_tax', 456 ) ); 457 458 $p = $this->factory->post->create(); 459 wp_set_object_terms( $p, $t->slug, 'wptests_tax' ); 460 461 $this->go_to( '/?wptests_tax=' . $t->slug ); 462 463 $this->assertFalse( is_tax( 'wptests_tax' ) ); 464 } 465 466 /** 467 * @ticket 21949 468 */ 469 public function test_nonpublic_taxonomy_should_not_be_queryable_using_taxonomy_and_term_vars() { 470 register_taxonomy( 'wptests_tax', 'post', array( 471 'public' => false, 472 ) ); 473 474 $t = $this->factory->term->create_and_get( array( 475 'taxonomy' => 'wptests_tax', 476 ) ); 477 478 $p = $this->factory->post->create(); 479 wp_set_object_terms( $p, $t->slug, 'wptests_tax' ); 480 481 $this->go_to( '/?taxonomy=wptests_tax&term=' . $t->slug ); 482 483 $this->assertFalse( is_tax( 'wptests_tax' ) ); 484 } 445 485 }