Ticket #39428: 39428.diff
File 39428.diff, 1.6 KB (added by , 8 years ago) |
---|
-
src/wp-includes/class-wp-query.php
2121 2121 } 2122 2122 $q['author_name'] = sanitize_title_for_query( $q['author_name'] ); 2123 2123 $q['author'] = get_user_by('slug', $q['author_name']); 2124 if ( $q['author'] ) 2124 if ( $q['author'] ) { 2125 2125 $q['author'] = $q['author']->ID; 2126 $whichauthor .= " AND ({$wpdb->posts}.post_author = " . absint($q['author']) . ')'; 2126 $whichauthor .= " AND ({$wpdb->posts}.post_author = " . absint($q['author']) . ')'; 2127 } else { 2128 $whichauthor .= " AND 1=0"; 2129 } 2127 2130 } 2128 2131 2129 2132 // MIME-Type stuff for attachment browsing -
tests/phpunit/tests/query/results.php
704 704 $feed_comment = $this->q->next_comment(); 705 705 $this->assertEquals( $comment_id, $feed_comment->comment_ID ); 706 706 } 707 708 /** 709 * @ticket 39428 710 */ 711 public function test_nonexisting_author_slug() { 712 self::factory()->post->create( array( 'post_author' => 1 ) ); 713 714 $posts = $this->q->query( array( 'author_name' => 'admin' ) ); 715 716 $this->assertNotEmpty( $posts ); 717 $this->assertNotRegExp( '#AND 1=0#', $this->q->request ); 718 719 $posts2 = $this->q->query( array( 'author_name' => 'noadmin' ) ); 720 721 $this->assertEmpty( $posts2 ); 722 $this->assertRegExp( '#AND 1=0#', $this->q->request ); 723 } 707 724 }