diff --git src/wp-includes/class-wp-query.php src/wp-includes/class-wp-query.php
index afc8f96..5fb8dc5 100644
|
|
class WP_Query { |
3030 | 3030 | * @param string $found_posts The query to run to find the found posts. |
3031 | 3031 | * @param WP_Query $this The WP_Query instance (passed by reference). |
3032 | 3032 | */ |
3033 | | $this->found_posts = $wpdb->get_var( apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ) ); |
| 3033 | $found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ); |
| 3034 | |
| 3035 | $this->found_posts = (int) $wpdb->get_var( $found_posts_query ); |
3034 | 3036 | } else { |
3035 | 3037 | $this->found_posts = count( $this->posts ); |
3036 | 3038 | } |
diff --git tests/phpunit/tests/post/query.php tests/phpunit/tests/post/query.php
index 6ae8114..995568c 100644
|
|
class Tests_Post_Query extends WP_UnitTestCase { |
535 | 535 | $this->assertEquals( 2, $q->found_posts ); |
536 | 536 | $this->assertEquals( 2, $q->max_num_pages ); |
537 | 537 | } |
| 538 | |
| 539 | /** |
| 540 | * The found_posts property should be of type int, not string. |
| 541 | * |
| 542 | * @ticket 42469 |
| 543 | */ |
| 544 | public function test_found_posts_should_be_integer_not_string() { |
| 545 | $this->post_id = self::factory()->post->create(); |
| 546 | |
| 547 | $q = new WP_Query( array( |
| 548 | 'posts_per_page' => 1, |
| 549 | ) ); |
| 550 | |
| 551 | $this->assertTrue( is_int( $q->found_posts ) ); |
| 552 | $this->assertFalse( is_string( $q->found_posts ) ); |
| 553 | } |
538 | 554 | } |