Query: Fix warning on counting non countable

Adds tests to continue the behavior for both null and strings.

See https://wiki.php.net/rfc/counting_non_countables for information on the PHP change.

Fixes #42860.
Props janak007 and ayeshrajans for initial patches.




Built from https://develop.svn.wordpress.org/trunk@42581


git-svn-id: http://core.svn.wordpress.org/trunk@42410 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Aaron Jorbin 2018-01-24 01:21:31 +00:00
parent 09432d1aa6
commit 8a884f562a
2 changed files with 10 additions and 2 deletions

View File

@ -3158,7 +3158,15 @@ class WP_Query {
*/
$this->found_posts = $wpdb->get_var( apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ) );
} else {
$this->found_posts = count( $this->posts );
if ( is_array( $this->posts ) ) {
$this->found_posts = count( $this->posts );
} else {
if ( null === $this->posts ) {
$this->found_posts = 0;
} else {
$this->found_posts = 1;
}
}
}
/**

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.0-alpha-42579';
$wp_version = '5.0-alpha-42581';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.