From d86fe35b7fc7a65970abde86e4f7f21566d025ac Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Mon, 20 Nov 2017 22:46:47 +0000 Subject: [PATCH] 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 --- wp-includes/class-wp-term-query.php | 7 ++++++- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/wp-includes/class-wp-term-query.php b/wp-includes/class-wp-term-query.php index d704f5e161..e27b68676b 100644 --- a/wp-includes/class-wp-term-query.php +++ b/wp-includes/class-wp-term-query.php @@ -379,7 +379,12 @@ class WP_Term_Query { } if ( ! $in_hierarchy ) { - return array(); + if ( 'count' == $args['fields'] ) { + return 0; + } else { + $this->terms = array(); + return $this->terms; + } } } diff --git a/wp-includes/version.php b/wp-includes/version.php index ab75fbd103..06e9bccf6d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @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.