[wp-trac] [WordPress Trac] #42327: WP_Term_Query returns an empty array instead of 0

WordPress Trac noreply at wordpress.org
Wed Oct 25 01:43:09 UTC 2017


#42327: WP_Term_Query returns an empty array instead of 0
--------------------------+------------------------------
 Reporter:  xParham       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Taxonomy      |     Version:  4.6
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by xParham):

 @westonruter That's when the `WP_Term_Query` was introduced which borrowed
 the code from `get_terms()`. Avoiding the query and returning an empty
 array if the queried parent/child_of term has no descendants had been in
 `get_terms()` since [6118] but there was no `count` option back then. The
 bug was actually introduced in [13491] via #10746 when the `count` option
 for the `fields` parameter was added but the part which handled the early
 bailing of the function wasn't updated to return 0 instead of an empty
 array if a `count` is the expected return value.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42327#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list