Changeset 48328
- Timestamp:
- 07/05/2020 09:32:26 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-query.php
r48114 r48328 3236 3236 * @since 2.1.0 3237 3237 * 3238 * @param string $found_posts The query to run to find the found posts.3239 * @param WP_Query $this The WP_Query instance (passed by reference).3238 * @param string $found_posts_query The query to run to find the found posts. 3239 * @param WP_Query $this The WP_Query instance (passed by reference). 3240 3240 */ 3241 $this->found_posts = $wpdb->get_var( apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ) ); 3241 $found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ); 3242 3243 $this->found_posts = (int) $wpdb->get_var( $found_posts_query ); 3242 3244 } else { 3243 3245 if ( is_array( $this->posts ) ) { … … 3260 3262 * @param WP_Query $this The WP_Query instance (passed by reference). 3261 3263 */ 3262 $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) );3264 $this->found_posts = (int) apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); 3263 3265 3264 3266 if ( ! empty( $limits ) ) { -
trunk/tests/phpunit/tests/post/query.php
r47122 r48328 653 653 654 654 add_filter( 'split_the_query', '__return_true' ); 655 655 656 $q = new WP_Query( 656 657 array( … … 659 660 ) 660 661 ); 662 661 663 remove_filter( 'split_the_query', '__return_true' ); 662 664 … … 678 680 // ! $split_the_query 679 681 add_filter( 'split_the_query', '__return_false' ); 682 680 683 $q = new WP_Query( 681 684 array( … … 684 687 ) 685 688 ); 689 686 690 remove_filter( 'split_the_query', '__return_false' ); 687 691 … … 722 726 } 723 727 728 /** 729 * @ticket 42469 730 */ 731 public function test_found_posts_should_be_integer_not_string() { 732 $this->post_id = self::factory()->post->create(); 733 734 $q = new WP_Query( 735 array( 736 'posts_per_page' => 1, 737 ) 738 ); 739 740 $this->assertInternalType( 'int', $q->found_posts ); 741 } 742 743 /** 744 * @ticket 42469 745 */ 746 public function test_found_posts_should_be_integer_even_if_found_posts_filter_returns_string_value() { 747 $this->post_id = self::factory()->post->create(); 748 749 add_filter( 'found_posts', '__return_empty_string' ); 750 751 $q = new WP_Query( 752 array( 753 'posts_per_page' => 1, 754 ) 755 ); 756 757 remove_filter( 'found_posts', '__return_empty_string' ); 758 759 $this->assertInternalType( 'int', $q->found_posts ); 760 } 724 761 }
Note: See TracChangeset
for help on using the changeset viewer.