Ticket #51794: 51794.2.diff
File 51794.2.diff, 1.4 KB (added by , 5 years ago) |
---|
-
src/wp-includes/class-wp-query.php
915 915 } 916 916 917 917 if ( '' !== $qv['author_name'] ) { 918 $this->is_author = true; 918 if ( get_user_by( 'slug', $qv['author_name'] ) ) { 919 $this->is_author = true; 920 } else { 921 $qv['error'] = '404'; 922 $qv['author'] = $qv['author_name']; 923 } 919 924 } 920 925 921 926 if ( ! empty( $qv['post_type'] ) && ! is_array( $qv['post_type'] ) ) { -
tests/phpunit/tests/query.php
696 696 $this->assertSame( 'tax1', get_query_var( 'taxonomy' ) ); 697 697 $this->assertSame( 'term1', get_query_var( 'term' ) ); 698 698 } 699 700 /** 701 * @ticket 51794 702 */ 703 public function test_nonexistent_author_query_should_not_return_results() { 704 $p1 = self::factory()->post->create( array( 'post_author' => 0 ) ); 705 706 $url = add_query_arg( 707 array( 708 'author_name' => 'thisuserdoesnotexist', 709 ), 710 '/' 711 ); 712 713 $this->go_to( $url ); 714 715 $matching_posts = wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ); 716 717 $this->assertTrue( $GLOBALS['wp_query']->is_404() ); 718 $this->assertEmpty( $matching_posts ); 719 } 720 699 721 }