[wp-trac] [WordPress Trac] #37728: hide_empty doesn't work correctly in get_terms when no taxonomy specified

WordPress Trac noreply at wordpress.org
Fri Aug 23 16:04:17 UTC 2019


#37728: hide_empty doesn't work correctly in get_terms when no taxonomy specified
-------------------------------------------------+-------------------------
 Reporter:  smerriman                            |       Owner:
                                                 |  boonebgorges
     Type:  defect (bug)                         |      Status:  closed
 Priority:  normal                               |   Milestone:  5.3
Component:  Taxonomy                             |     Version:  4.5
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  has-patch needs-unit-tests           |     Focuses:
  reporter-feedback needs-testing                |
-------------------------------------------------+-------------------------
Changes (by boonebgorges):

 * owner:  (none) => boonebgorges
 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"45888" 45888]:
 {{{
 #!CommitTicketReference repository="" revision="45888"
 Taxonomy: Ensure consistency of `hide_empty` in term queries when
 `taxonomy` is excluded.

 When querying for terms in hierarchical categories using
 `hide_empty=true`,
 results have historically included parent terms which are themselves
 unattached to any objects (are "empty") but which have non-empty
 descendent
 terms. Because this process involves walking the descendant tree, we avoid
 it
 when we detect that the queried taxonomies are not hierarchical. (This
 behavior was introduced in [5525].)

 When the `taxonomy` parameter of `get_terms()` was made optional - see
 #35495,
 [36614] - it affected the mechanism for avoiding unneccessary tree walks,
 since there may not be any explicitly declared taxonomies to run through
 `is_taxonomy_hierarchical()`. As a result, term queries excluding
 `taxonomy`
 did not check descendants, and empty parents with non-empty children were
 not
 included in `hide_empty` results.

 We correct the behavior by crawling term descendants when the `taxonomy`
 argument is absent, which means that we're querying for terms in all
 taxonomies.

 Props smerriman.
 Fixes #37728.
 }}}

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


More information about the wp-trac mailing list