Changeset 54496
- Timestamp:
- 10/11/2022 06:13:34 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-query.php
r54464 r54496 3964 3964 3965 3965 $post_obj = $this->get_queried_object(); 3966 if ( ! $post_obj ) { 3967 return false; 3968 } 3966 3969 3967 3970 if ( in_array( (string) $post_obj->ID, $attachment, true ) ) { … … 3997 4000 3998 4001 $author_obj = $this->get_queried_object(); 4002 if ( ! $author_obj ) { 4003 return false; 4004 } 3999 4005 4000 4006 $author = array_map( 'strval', (array) $author ); … … 4033 4039 4034 4040 $cat_obj = $this->get_queried_object(); 4041 if ( ! $cat_obj ) { 4042 return false; 4043 } 4035 4044 4036 4045 $category = array_map( 'strval', (array) $category ); … … 4069 4078 4070 4079 $tag_obj = $this->get_queried_object(); 4080 if ( ! $tag_obj ) { 4081 return false; 4082 } 4071 4083 4072 4084 $tag = array_map( 'strval', (array) $tag ); … … 4316 4328 4317 4329 $page_obj = $this->get_queried_object(); 4330 if ( ! $page_obj ) { 4331 return false; 4332 } 4318 4333 4319 4334 $page = array_map( 'strval', (array) $page ); … … 4423 4438 4424 4439 $post_obj = $this->get_queried_object(); 4440 if ( ! $post_obj ) { 4441 return false; 4442 } 4425 4443 4426 4444 $post = array_map( 'strval', (array) $post ); … … 4470 4488 4471 4489 $post_obj = $this->get_queried_object(); 4490 if ( ! $post_obj ) { 4491 return false; 4492 } 4472 4493 4473 4494 return in_array( $post_obj->post_type, (array) $post_types, true ); -
trunk/tests/phpunit/tests/query.php
r54464 r54496 789 789 $this->assertFalse( is_post_type_archive( $post_type ) ); 790 790 } 791 792 /** 793 * @ticket 29660 794 */ 795 public function test_query_singular_404_does_not_throw_warning() { 796 $q = new WP_Query( 797 array( 798 'pagename' => 'non-existent-page', 799 ) 800 ); 801 802 $this->assertSame( 0, $q->post_count ); 803 $this->assertFalse( $q->is_single() ); 804 805 $this->assertTrue( $q->is_singular() ); 806 $this->assertFalse( $q->is_singular( 'page' ) ); 807 808 $this->assertTrue( $q->is_page() ); 809 $this->assertFalse( $q->is_page( 'non-existent-page' ) ); 810 } 811 812 /** 813 * @ticket 29660 814 */ 815 public function test_query_single_404_does_not_throw_warning() { 816 $q = new WP_Query( 817 array( 818 'name' => 'non-existent-post', 819 ) 820 ); 821 822 $this->assertSame( 0, $q->post_count ); 823 $this->assertFalse( $q->is_page() ); 824 825 $this->assertTrue( $q->is_singular() ); 826 $this->assertFalse( $q->is_singular( 'post' ) ); 827 828 $this->assertTrue( $q->is_single() ); 829 $this->assertFalse( $q->is_single( 'non-existent-post' ) ); 830 } 831 832 /** 833 * @ticket 29660 834 */ 835 public function test_query_attachment_404_does_not_throw_warning() { 836 $q = new WP_Query( 837 array( 838 'attachment' => 'non-existent-attachment', 839 ) 840 ); 841 842 $this->assertSame( 0, $q->post_count ); 843 844 $this->assertTrue( $q->is_singular() ); 845 $this->assertFalse( $q->is_singular( 'attachment' ) ); 846 847 $this->assertTrue( $q->is_attachment() ); 848 $this->assertFalse( $q->is_attachment( 'non-existent-attachment' ) ); 849 } 850 851 /** 852 * @ticket 29660 853 */ 854 public function test_query_author_404_does_not_throw_warning() { 855 $q = new WP_Query( 856 array( 857 'author_name' => 'non-existent-author', 858 ) 859 ); 860 861 $this->assertSame( 0, $q->post_count ); 862 863 $this->assertTrue( $q->is_author() ); 864 $this->assertFalse( $q->is_author( 'non-existent-author' ) ); 865 } 866 867 /** 868 * @ticket 29660 869 */ 870 public function test_query_category_404_does_not_throw_warning() { 871 $q = new WP_Query( 872 array( 873 'category_name' => 'non-existent-category', 874 ) 875 ); 876 877 $this->assertSame( 0, $q->post_count ); 878 879 $this->assertTrue( $q->is_category() ); 880 $this->assertFalse( $q->is_tax() ); 881 $this->assertFalse( $q->is_category( 'non-existent-category' ) ); 882 } 883 884 /** 885 * @ticket 29660 886 */ 887 public function test_query_tag_404_does_not_throw_warning() { 888 $q = new WP_Query( 889 array( 890 'tag' => 'non-existent-tag', 891 ) 892 ); 893 894 $this->assertSame( 0, $q->post_count ); 895 896 $this->assertTrue( $q->is_tag() ); 897 $this->assertFalse( $q->is_tax() ); 898 $this->assertFalse( $q->is_tag( 'non-existent-tag' ) ); 899 } 791 900 }
Note: See TracChangeset
for help on using the changeset viewer.