[wp-trac] [WordPress Trac] #29851: term_exists gives back the wrong term when it has parents
WordPress Trac
noreply at wordpress.org
Fri Oct 3 14:39:34 UTC 2014
#29851: term_exists gives back the wrong term when it has parents
--------------------------+---------------------------
Reporter: allaerd | Owner: boonebgorges
Type: defect (bug) | Status: accepted
Priority: normal | Milestone: 4.1
Component: Taxonomy | Version: 4.0
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
--------------------------+---------------------------
Changes (by boonebgorges):
* keywords: => has-patch
* owner: => boonebgorges
* status: new => accepted
* milestone: Awaiting Review => 4.1
Comment:
Confirmed. The problem is that passing a `parent` of 0 causes the parent
clause to be bypassed. That means that there is no way to use
`term_exists()` and filter by top-level terms.
[attachment:29851.patch] contains a unit test demonstrating the problem,
as well as a suggested fix. In brief: change the default value of
`$parent` from 0 to null, and build the parent SQL clause whenever the
value of `$parent` is numeric. Use of `term_exists()` with no parent param
will remain the same, as will its use when passing a non-zero integer. It
fixes this bug (passing a 0 or '0' is now interpreted correctly).
allaerd, is it possible for you to test this change to see if it solves
your problem?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29851#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list