#29851 closed defect (bug) (fixed)
term_exists gives back the wrong term when it has parents
Reported by: | allaerd | Owned by: | boonebgorges |
---|---|---|---|
Milestone: | 4.1 | Priority: | normal |
Severity: | normal | Version: | 4.0 |
Component: | Taxonomy | Keywords: | has-patch |
Focuses: | Cc: |
Description
when i have this terms
server->hp->ram
and i call
term_exists( 'hp' , 'product_cat', 0);
i expect to get back false
when i have this
hp->ram
i expect to get back a positive result
Attachments (1)
Change History (6)
Note: See
TracTickets for help on using
tickets.
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 useterm_exists()
and filter by top-level terms.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 ofterm_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?