Query: Fix warning on counting non countable

Merges [42581], [42585], and [42594] to the 4.9 branch.

Adds tests to continue the behavior for both null and strings. Skip the tests on PHP 5.2 as they require ReflectionMethod.

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

Fixes #42860.
Props dd32 for test skipping and janak007 and ayeshrajans for initial patches.

Built from https://develop.svn.wordpress.org/branches/4.9@42597


git-svn-id: http://core.svn.wordpress.org/branches/4.9@42426 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Aaron Jorbin 2018-01-24 21:44:42 +00:00
parent 4224f6e214
commit f0fd88a7f5
2 changed files with 10 additions and 2 deletions

View File

@ -3032,7 +3032,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 = '4.9.3-alpha-42596';
$wp_version = '4.9.3-alpha-42597';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.