Make WordPress Core


Ignore:
Timestamp:
07/05/2020 09:32:26 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-query.php

    r48114 r48328  
    32363236             * @since 2.1.0
    32373237             *
    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).
    32403240             */
    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 );
    32423244        } else {
    32433245            if ( is_array( $this->posts ) ) {
     
    32603262         * @param WP_Query $this        The WP_Query instance (passed by reference).
    32613263         */
    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 ) );
    32633265
    32643266        if ( ! empty( $limits ) ) {
Note: See TracChangeset for help on using the changeset viewer.