Improve data types returned from empty hierarchical term queries.

When querying for 'count', ensure that 0 is returned. Otherwise,
ensure that it's an array.

Props xParham, birgire.
Fixes #42327.
Built from https://develop.svn.wordpress.org/trunk@42209


git-svn-id: http://core.svn.wordpress.org/trunk@42038 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2017-11-20 22:46:47 +00:00
parent aed08a0f25
commit d86fe35b7f
2 changed files with 7 additions and 2 deletions

View File

@ -379,7 +379,12 @@ class WP_Term_Query {
} }
if ( ! $in_hierarchy ) { if ( ! $in_hierarchy ) {
return array(); if ( 'count' == $args['fields'] ) {
return 0;
} else {
$this->terms = array();
return $this->terms;
}
} }
} }

View File

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