[wp-trac] [WordPress Trac] #29185: get_terms with parent set incorrectly hides non-empty terms
WordPress Trac
noreply at wordpress.org
Mon Oct 27 03:50:14 UTC 2014
#29185: get_terms with parent set incorrectly hides non-empty terms
------------------------------+------------------------------
Reporter: smerriman | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: 3.9.1
Severity: normal | Resolution:
Keywords: needs-unit-tests | Focuses:
------------------------------+------------------------------
Comment (by landakram):
I wrote some additional unit tests that describe the interplay between
`child_of`, `parent`, and `hierarchical`. I used this hierarchy for the
tests:
* One
* Two
* Three (1)
* Four
* Five
* Six (1)
* Seven
Here's what I found:
1. When `hierarchical == true` and `child_of` is set, both children
''and'' non-empty descendants are returned. In other words, in the
hierarchy described, Two, Three, Five, and Six are returned.
2. When `hierarchical == false` and `child_of` is set, only direct
children are returned. In the above hierarchy, the returned array is
''empty''. I wrote another test which the hierarchy so that a post was
associated with Seven, and the returned array contained only Seven.
3. When both `child_of` and `parent` are set, `parent` takes precedent
over `child_of`.
4. When `hierarchical == true` and `parent` is set, the returned array is
empty. '''This is the bug''' — it should return Two and Five.
5. When `hierarchical == false` and `parent` is set, the returned array is
empty.
6. When `hierarchical == true` and both `child_of` and `parent` are set,
the returned array is empty. '''This is the bug''' — to be consistent with
the behavior of #3, it should return Two and Five.
7. When `hierarchical == false` and both `child_of` and `parent` are set,
the returned array is empty.
The attached patch includes the unit tests and the fix that boonebgorges
and I came up with. When patched, #4 and #5 are fixed
(`test_hierarchical_parent_get_terms` and
`test_hierarchical_parent_child_of_get_terms` respectively).
Now, I can't say whether the existing behaviors make 'sense', but the
proposed patch leaves those behaviors intact while fixing this bug :)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29185#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list