From 4e3bad17702f8fe0152e410de90186c1c4bc5f76 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 5 Jul 2020 21:34:02 +0000 Subject: [PATCH] Query: Make sure the `found_posts` property of `WP_Query` is always an integer, to match the documented type. This makes the property consistent with similar properties of other classes: * `WP_Comment_Query::$found_comments` * `WP_Network_Query::$found_networks` * `WP_Site_Query::$found_sites` * `WP_User_Query::$total_users` Props birgire, PressLabs. Fixes #42469. Built from https://develop.svn.wordpress.org/trunk@48328 git-svn-id: http://core.svn.wordpress.org/trunk@48097 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-query.php | 10 ++++++---- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/wp-includes/class-wp-query.php b/wp-includes/class-wp-query.php index 06d531c39a..6508e7f64e 100644 --- a/wp-includes/class-wp-query.php +++ b/wp-includes/class-wp-query.php @@ -3235,10 +3235,12 @@ class WP_Query { * * @since 2.1.0 * - * @param string $found_posts The query to run to find the found posts. - * @param WP_Query $this The WP_Query instance (passed by reference). + * @param string $found_posts_query The query to run to find the found posts. + * @param WP_Query $this The WP_Query instance (passed by reference). */ - $this->found_posts = $wpdb->get_var( apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ) ); + $found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ); + + $this->found_posts = (int) $wpdb->get_var( $found_posts_query ); } else { if ( is_array( $this->posts ) ) { $this->found_posts = count( $this->posts ); @@ -3259,7 +3261,7 @@ class WP_Query { * @param int $found_posts The number of posts found. * @param WP_Query $this The WP_Query instance (passed by reference). */ - $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); + $this->found_posts = (int) apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); if ( ! empty( $limits ) ) { $this->max_num_pages = ceil( $this->found_posts / $q['posts_per_page'] ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 0cc2601986..4bf0b7d7fb 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-48327'; +$wp_version = '5.5-alpha-48328'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.