[wp-trac] [WordPress Trac] #27123: get_categories returning duplicate child categories in 3.9
WordPress Trac
noreply at wordpress.org
Thu Feb 20 04:18:49 UTC 2014
#27123: get_categories returning duplicate child categories in 3.9
----------------------------------------+--------------------
Reporter: BStofko | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 3.9
Component: Taxonomy | Version: trunk
Severity: normal | Resolution:
Keywords: needs-unit-tests has-patch | Focuses:
----------------------------------------+--------------------
Changes (by SergeyBiryukov):
* keywords: needs-patch needs-unit-tests => needs-unit-tests has-patch
Comment:
So, we have a public function `get_term_children()`, which returns all
child IDs of an item, and a private function `_get_term_children()`, which
only returns child items (IDs or objects) from a given subset.
It looks like the changes to `_get_term_children()` in [27108] and [27125]
were an attempt to make it work like `get_term_children()`, i.e. return
all child IDs, regardless of the passed subset. This leads to duplicated
results when using `child_of`, due to the same items being added to the
`$term_list` array twice.
Instead, I think the correct fix for both #26903 and this ticket would be
to revert those changes and just use `get_term_children()` in
`get_terms()` when dealing with `hierarchical`.
This is confirmed by unit tests, however they still intermittently fail
for some unknown reason, as noted in IRC:
http://irclogs.wordpress.org/chanlog.php?channel=wordpress-
dev&day=2014-02-19&sort=asc#m794718
[attachment:27123.patch] contains the fix and the new test. It also makes
assertions for #26903 a bit more accurate.
`delete_option()` hack looks weird, but it seems to be required for
`get_terms()` to work properly in the test.
`test_get_terms_exclude_tree()` has the same hack:
[source:tags/3.8.1/tests/phpunit/tests/term/getTerms.php#L168] (added in
[25933]).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27123#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list